-
Notifications
You must be signed in to change notification settings - Fork 3
88 lines (72 loc) · 2.98 KB
/
auto_upgrade.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# 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