-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (59 loc) · 2 KB
/
PROD-publish.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
name: PROD Publish Package to npm
on:
push:
branches:
- main
jobs:
prod_test:
runs-on: [self-hosted]
env:
MNEMONIC: ${{ secrets.MNEMONIC }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies🔧
run: npm install
- name: Run the tests 🧪
run: npm run test-unit
publish:
needs: prod_test
runs-on: [self-hosted]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies and build 🔧
run: npm install && npm run build
- name: Check if version has changed
id: version_check
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
NPM_VERSION=$(npm show juneojs version)
if [[ "$CURRENT_VERSION" != "$NPM_VERSION" ]]; then
echo "New version detected: $CURRENT_VERSION"
echo "should_publish=true" >> $GITHUB_ENV
else
echo "No new version detected."
echo "should_publish=false" >> $GITHUB_ENV
fi
- name: Publish package on NPM 📦
if: env.should_publish == 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Trigger juneojs-examples upgrade workflow
if: env.should_publish == 'true'
run: |
curl -X POST https://api.github.com/repos/Juneo-io/juneojs-examples/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ secrets.ACTIONS_KEY }}" \
--data '{"event_type": "Trigger Workflow", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'" }}'