-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NPM publish from GHA #40
Conversation
Align build.yml with similar projects
- run: npm publish | ||
if: github.event_name == 'release' && github.event.action == 'created' | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take it we need to add the NPM_TOKEN
secret to this repository.
Is that generate from a specific account?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it's an org secret, so should work out-of-the-box 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an org secret enabled for specific repos and I added this one.
on: | ||
release: | ||
types: [created] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be triggered when we "draft a new release"? I have used the type published
in the past.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it doesn't apply to drafts, although the docs are not very clear as to what's the difference: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we trust this StackOverflow response, if we use release scripts (which we currently don't) could end-up only triggering a published
event: https://stackoverflow.com/a/61066906/775259
Not really using that at the moment, so happy to merge it as is, if you want to keep all CI scripts the same, but worth knowing for the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty convinced it won't run for drafts but agree it may not run when a draft is published either, would need to test as the docs are unclear. I have a BAU ticket open to investigate this and will go back and update workflows based on that investigation.
.github/workflows/build.yml
Outdated
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this isn't published to the GH package registry, no? Only npm.
In that case we probably don't need to add packages: write
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah which I suppose this will never do so fair to remove it. Will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.github/workflows/build.yml
Outdated
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is only needed if using private packages from the GH package registry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah which I suppose this will never do so fair to remove it. Will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Thanks Matt!
Align build.yml with similar projects