Skip to content

Commit face55c

Browse files
feat: improve update ci script
1 parent 66b28e6 commit face55c

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

.github/workflows/.spell.yml.swo

-12 KB
Binary file not shown.

.github/workflows/spell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
2929
with:
3030
persist-credentials: false
31-
- uses: reviewdog/action-misspell@e7ea17f144822818706c7e579de7927d59384575 # 1.27.0
31+
- uses: reviewdog/action-misspell@d6429416b12b09b4e2768307d53bef58d172e962 # 1.27.0
3232
with:
3333
github_token: ${{ secrets.github_token }}
3434
check-spellcheck:

ci/update_versions.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,34 @@ if [[ ${DEBUG:-false} == "true" ]]; then
1414
set -o xtrace
1515
fi
1616

17+
trap "make fmt" EXIT
18+
1719
eval "$(curl -fsSL https://raw.githubusercontent.com/electrocucaracha/pkg-mgr_scripts/master/ci/pinned_versions.env)"
1820

1921
sed -i "s|PKG_VAGRANT_VERSION:-.*|PKG_VAGRANT_VERSION:-$PKG_VAGRANT_VERSION}|g" setup.sh
2022
sed -i "s/vagrant version.*/vagrant version | awk 'NR==1\{print \$3}')\" != \"$PKG_VAGRANT_VERSION\" \]\]; then/g" validate.sh
2123

24+
go_version="$(curl -sL https://golang.org/VERSION?m=text | sed -n 's/go//;s/\..$//;1p')"
25+
find .github/workflows -type f \( -name '*.yml' -o -name '*.yaml' \) \
26+
-exec grep -l 'go-version:' {} + \
27+
-exec env go_version="${go_version}" bash -s {} + <<'EOF'
28+
for file; do
29+
sed -i \
30+
"s|^\([[:space:]]*go-version:[[:space:]]*\).*|\
31+
\1\"^${go_version}\"|" \
32+
"${file}"
33+
done
34+
EOF
35+
2236
# Update GitHub Action commit hashes
23-
gh_actions=$(grep -r "uses: [a-zA-Z\-]*/[\_a-z\-]*@" .github/ | sed 's/@.*//' | awk -F ': ' '{ print $3 }' | sort -u)
37+
gh_actions=$(grep -r "uses: [A-Za-z0-9_.-]*/[\_a-z\-]*@" .github/ | sed 's/@.*//' | awk -F ': ' '{ print $3 }' | sort -u)
38+
exceptions=('reviewdog/action-misspell' 'actions/attest-build-provenance' 'GrantBirki/git-diff-action')
2439
for action in $gh_actions; do
25-
commit_hash=$(git ls-remote "https://github.com/$action" | grep 'refs/tags/[v]\?[0-9][0-9\.]*$' | sed 's|refs/tags/[vV]\?[\.]\?||g' | sort -u -k2 -V | tail -1 | awk '{ printf "%s # %s\n",$1,$2 }')
40+
if [[ ${exceptions[*]} =~ (^|[^[:alpha:]])$action([^[:alpha:]]|$) ]]; then
41+
commit_hash=$(git ls-remote "https://github.com/$action" | grep 'refs/tags/[v]\?[0-9][0-9\.]*\^{}$' | sed 's|refs/tags/[vV]\?[\.]\?||g; s|\^{}$||g' | sort -u -k2 -V | tail -1 | awk '{ printf "%s # %s\n",$1,$2 }')
42+
else
43+
commit_hash=$(git ls-remote "https://github.com/$action" | grep 'refs/tags/[v]\?[0-9][0-9\.]*$' | sed 's|refs/tags/[vV]\?[\.]\?||g' | sort -u -k2 -V | tail -1 | awk '{ printf "%s # %s\n",$1,$2 }')
44+
fi
2645
# shellcheck disable=SC2267
2746
grep -ElRZ "uses: $action@" .github/ | xargs -0 -l sed -i -e "s|uses: $action@.*|uses: $action@$commit_hash|g"
2847
done
29-
make fmt

0 commit comments

Comments
 (0)