Skip to content

Commit f9541bb

Browse files
authored
[SC-58776] Publish Pipeline package to NPM and Github (#76)
1 parent a2b0697 commit f9541bb

File tree

2 files changed

+59
-11
lines changed

2 files changed

+59
-11
lines changed

.github/workflows/action-lint.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
# copied from https://github.com/Fieldguide/github-actions-common/blob/main/.github/workflows/action-lint.yaml
2+
13
name: Action Lint
24
on:
35
pull_request:
4-
paths:
5-
- .github/**/*.ya?ml
6+
workflow_call:
67
jobs:
7-
ci:
8-
uses: fieldguide/github-actions-common/.github/workflows/action-lint.yaml@main
8+
actionlint:
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: reviewdog/action-actionlint@v1.65.2
13+
with:
14+
actionlint_flags: "-shellcheck= "
15+
fail_level: error

.github/workflows/publish.yml

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Publish to npm"
1+
name: "Publish package"
22

33
on:
44
release:
@@ -14,22 +14,29 @@ env:
1414
SLACK_DEPLOY_ERROR_REACTION: ${{ vars.SLACK_DEPLOY_ERROR_REACTION_PRODUCTION }}
1515

1616
jobs:
17-
publish:
17+
start:
1818
runs-on: ubuntu-latest
19+
outputs:
20+
thread_ts: ${{ steps.slack.outputs.ts }}
21+
version: ${{ steps.version.outputs.value }}
1922
steps:
2023
- name: Post to Slack
2124
uses: Fieldguide/action-slack-deploy-pipeline@v2
2225
id: slack
2326

24-
- name: Checkout code
25-
uses: actions/checkout@v4
26-
2727
- name: Parse version
2828
id: version
2929
run: echo "value=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT
3030

31+
publish-npm:
32+
needs: start
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
3138
- name: Update npm package version for build / publishing
32-
run: npm version ${{ steps.version.outputs.value }} --no-git-tag-version
39+
run: npm version ${{ needs.start.outputs.version }} --no-git-tag-version
3340

3441
- name: Setup Node.js
3542
uses: actions/setup-node@v4
@@ -47,9 +54,43 @@ jobs:
4754
env:
4855
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4956

57+
publish-github:
58+
needs: start
59+
runs-on: ubuntu-latest
60+
permissions:
61+
packages: write
62+
steps:
63+
- name: Checkout code
64+
uses: actions/checkout@v4
65+
66+
- name: Update npm package version for build / publishing
67+
run: npm version ${{ needs.start.outputs.version }} --no-git-tag-version
68+
69+
- name: Setup Node.js
70+
uses: actions/setup-node@v4
71+
with:
72+
node-version-file: ".nvmrc"
73+
cache: "npm"
74+
registry-url: "https://npm.pkg.github.com"
75+
76+
- name: Install dependencies
77+
run: npm ci --prefer-offline --no-audit
78+
79+
- name: Publish package
80+
run: npm publish --access public
81+
env:
82+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
84+
finish:
85+
needs:
86+
- start
87+
- publish-npm
88+
- publish-github
89+
runs-on: ubuntu-latest
90+
steps:
5091
- name: "Post to Slack"
5192
uses: Fieldguide/action-slack-deploy-pipeline@v2
5293
if: always()
5394
with:
54-
thread_ts: ${{ steps.slack.outputs.ts }}
95+
thread_ts: ${{ needs.start.outputs.thread_ts }}
5596
conclusion: true

0 commit comments

Comments
 (0)