Have the action output a versioning element so it could be used as part of the cache restore key (#239)

* Do a bit of YAMLlint'ing

* Ease consumer cache invalidation

By providing an output with the action version we ease
cache invalidation on consumer, due to the fact we can
now stop worrying about changes to the action's cache itself

Might also be interesting for self-hosted runners...

* Remove duplicates

* Do further validations for robustness
This commit is contained in:
Paulo F. Oliveira
2024-01-12 19:46:16 +00:00
committed by GitHub
parent a34c98fd51
commit 4678b57fab
6 changed files with 54 additions and 20 deletions
+25
View File
@@ -7,6 +7,31 @@ env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
jobs:
version:
name: Version with commit unique id
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Version it!
run: |
# We expect a string such as const setupBeamVersion = 'undefined' in the code
SHA=$(git rev-parse --short HEAD)
sed -i'.bak' \
-e "s/const setupBeamVersion = '.*'/const setupBeamVersion = '${SHA}'/g" \
dist/index.js
# it always starts by being 'undefined'
NEWVER=$(grep -oE "const setupBeamVersion = '.*'" dist/index.js | cut -d\' -f2)
if [ "$NEWVER" == "undefined" ]; then
exit 1
else
echo "Continuing... new version is ${NEWVER}"
fi
git config user.name "GitHub Actions"
git config user.email "actions@user.noreply.github.com"
git add dist/index.js
git commit -m "Update setup-beam version output to ${SHA}"
git push origin main
check_integrity:
name: Expected local npm actions
runs-on: ubuntu-latest