forked from boostercloud/booster
-
Notifications
You must be signed in to change notification settings - Fork 1
81 lines (70 loc) · 2.4 KB
/
wf_publish-npm.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
name: Publish to npm
on:
push:
branches:
- 'main'
paths-ignore:
- '**.md'
- 'website/**'
- '.github/**'
- '.vscode/**'
- 'packages/**/.vscode/**'
jobs:
integration-tests:
if: "!contains(github.event.head_commit.author.name, 'GITHUBACTION')"
name: Ensuring integration tests pass before publishing
uses: ./.github/workflows/wf_test-integration.yml
secrets: inherit
publish-npm:
if: "!contains(github.event.head_commit.author.name, 'GITHUBACTION')"
name: Publish to npm
needs: integration-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # required for Rush change
token: ${{ secrets.GITHUB_TOKEN_ACTION }}
# Workaround for https://github.com/actions/checkout/issues/6#issuecomment-520636057
- name: Prepare repository
run: git checkout "${GITHUB_REF:11}"
- name: Configure Git
run: |
git remote rm origin
git remote add origin "https://$USER_NAME:$GITHUB_PAT@github.com/boostercloud/booster.git"
git fetch
git config --local user.email "action@github.com"
git config --local user.name "GITHUBACTION"
git config pull.rebase true
env:
USER_NAME: ${{ secrets.DEPLOYING_USER_NAME }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN_ACTION }} # Token for pushing
- uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://registry.npmjs.org/
- name: Rush Update
uses: ./.github/actions/call-rush
with:
command: update
- name: Rush Install
uses: ./.github/actions/call-rush
with:
command: install
- name: Rush Build
uses: ./.github/actions/call-rush
with:
command: build
# Discard all changes that might have occurred after change build
- run: git stash
- name: Authenticate with Registry
run: npm config set "//registry.npmjs.org/:_authToken" "$NPM_TOKEN"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish using Rush
uses: ./.github/actions/call-rush
with:
command: publish --apply --publish --target-branch main --add-commit-details
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN_ACTION }}