Skip to content

Commit

Permalink
docs: add GitHub Package Registry example workflow (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous authored Jul 9, 2023
1 parent d2a7a65 commit c6846a9
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,35 @@ jobs:
token: ${{ secrets.NPM_TOKEN }}
```

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`:

```yaml
on:
push:
branches: main

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # allow GITHUB_TOKEN to publish packages
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18"
- run: npm ci
- run: npm test
- uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
registry: "https://npm.pkg.github.com"
```
[workflow file]: https://help.github.com/en/actions/automating-your-workflow-with-github-actions
[npm authentication token]: https://docs.npmjs.com/creating-and-viewing-authentication-tokens
[GitHub Package Registry]: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry
### Usage
Expand Down Expand Up @@ -169,8 +196,7 @@ steps:
token: ${{ secrets.NPM_TOKEN }}
- if: ${{ steps.publish.outputs.type }}
run: |
echo "Version changed!"
run: echo "Version changed!"
```

| Name | Type | Description |
Expand Down

0 comments on commit c6846a9

Please sign in to comment.