feat: blue to be safe #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | |
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | |
name: Auto Commit Updates Tokens | |
on: | |
push: | |
paths: | |
- tokens/** | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
HAVE_GIT_DEPLOY_KEY: ${{ secrets.DEPLOY_KEY != '' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ssh-key: ${{ secrets.DEPLOY_KEY }} | |
- uses: git-actions/set-user@v1 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | |
name: List the state of node modules | |
continue-on-error: true | |
run: npm list | |
- name: Install #run on lint step (Which is cached) | |
run: | # Install packages | |
npm install --prefer-offline --no-audit --ignore-scripts | |
# `npm rebuild` will run all those post-install scripts for us. | |
- name: rebuild and prepare | |
run: npm rebuild && npm run prepare --if-present | |
- run: npm run test | |
- name: Commit and push | |
run: | | |
if [[ "${GITHUB_REF}" == refs/heads/* ]]; then | |
branch=${GITHUB_REF#refs/heads/} | |
echo "branch: ${branch}" | |
if [ -z "$(git status -s)" ] ; then | |
git commit -m"Auto Commit Updates Tokens" -a | |
git push origin ${branch} | |
else | |
echo "No changes, script exited" | |
fi | |
else | |
echo "Not a branch" | |
fi | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: Tokens | |
path: ./dist | |
- name: Git Commit - Is Skipped | |
if: ${{ env.HAVE_GIT_DEPLOY_KEY != 'true' }} | |
run: | | |
echo "### Deployment config not configured" >> $GITHUB_STEP_SUMMARY | |
echo "secrets.DEPLOY_KEY not existing, npm version can't be pushed" >> $GITHUB_STEP_SUMMARY | |
echo "If this is a fork, please setup your own personal service account to publish to your own repo" >> $GITHUB_STEP_SUMMARY | |
echo "## We recommend using a service account with the least permissions necessary." >> $GITHUB_STEP_SUMMARY | |
echo "[Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)" >> $GITHUB_STEP_SUMMARY |