Skip to content

Commit c6846a9

Browse files
authored
docs: add GitHub Package Registry example workflow (#118)
1 parent d2a7a65 commit c6846a9

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,35 @@ jobs:
131131
token: ${{ secrets.NPM_TOKEN }}
132132
```
133133

134+
You can also publish to third-party registries. For example, to publish to the [GitHub Package Registry][], set `token` to `secrets.GITHUB_TOKEN` and `registry` to `https://npm.pkg.github.com`:
135+
136+
```yaml
137+
on:
138+
push:
139+
branches: main
140+
141+
jobs:
142+
publish:
143+
runs-on: ubuntu-latest
144+
permissions:
145+
contents: read
146+
packages: write # allow GITHUB_TOKEN to publish packages
147+
steps:
148+
- uses: actions/checkout@v3
149+
- uses: actions/setup-node@v3
150+
with:
151+
node-version: "18"
152+
- run: npm ci
153+
- run: npm test
154+
- uses: JS-DevTools/npm-publish@v2
155+
with:
156+
token: ${{ secrets.GITHUB_TOKEN }}
157+
registry: "https://npm.pkg.github.com"
158+
```
159+
134160
[workflow file]: https://help.github.com/en/actions/automating-your-workflow-with-github-actions
135161
[npm authentication token]: https://docs.npmjs.com/creating-and-viewing-authentication-tokens
162+
[GitHub Package Registry]: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry
136163
137164
### Usage
138165
@@ -169,8 +196,7 @@ steps:
169196
token: ${{ secrets.NPM_TOKEN }}
170197
171198
- if: ${{ steps.publish.outputs.type }}
172-
run: |
173-
echo "Version changed!"
199+
run: echo "Version changed!"
174200
```
175201

176202
| Name | Type | Description |

0 commit comments

Comments
 (0)