1
- name : Release
1
+ name : Publish to GitHub Packages Registry
2
2
3
3
on :
4
- workflow_dispatch :
4
+ push :
5
+ branches :
6
+ - testing
7
+ - production
5
8
6
9
jobs :
7
10
release :
8
11
name : Release
9
- runs-on : ubuntu-latest
12
+ runs-on : buildjet-2vcpu- ubuntu-2204-arm
10
13
steps :
11
- - run : echo "Placeholder"
14
+ - name : Checkout
15
+ uses : actions/checkout@v4
16
+
17
+ - name : Setup Node.js
18
+ uses : actions/setup-node@v4
19
+ with :
20
+ node-version-file : ' .nvmrc'
21
+ registry-url : ' https://npm.pkg.github.com'
22
+
23
+ - name : Build
24
+ run : |
25
+ npm ci --audit=false
26
+ npm run build
27
+ env :
28
+ NODE_AUTH_TOKEN : ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}
29
+
30
+ # Sets package.json name & version to environment.
31
+ - name : Get Package Info
32
+ run : |
33
+ NAME="$(node -p "require('./package.json').name")"
34
+ echo package_name=${NAME} >> $GITHUB_ENV
35
+
36
+ VERSION="$(node -p "require('./package.json').version")"
37
+ echo package_version=${VERSION} >> $GITHUB_ENV
38
+
39
+ # Publish when this action is running on branch production.
40
+ - name : Publish
41
+ if : github.ref == 'refs/heads/production'
42
+ env :
43
+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
44
+ run : |
45
+ npm publish
46
+
47
+ # Publish to beta when this action is running on branch testing.
48
+ - name : Publish (beta)
49
+ if : github.ref == 'refs/heads/testing'
50
+ env :
51
+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
52
+ run : |
53
+ npm publish --tag beta
54
+
55
+ # Post a Slack notification on success/failure
56
+ - name : Slack notify
57
+ if : always()
58
+ uses : innocarpe/actions-slack@v1
59
+ with :
60
+ status : ${{ job.status }}
61
+ success_text : ' ${{github.repository}} - Published ${{ env.package_name }}@${{ env.package_version }} to GitHub Packages Registry 🚀'
62
+ failure_text : ' ${{github.repository}} - Failed to publish ${{ env.package_name }}@${{ env.package_version }} to GitHub Packages Registry'
63
+ env :
64
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
65
+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
0 commit comments