Skip to content

Commit

Permalink
improve GitHub actions docs + remove unnecessary warning
Browse files Browse the repository at this point in the history
  • Loading branch information
hipstersmoothie committed Feb 23, 2021
1 parent e77a47c commit 9c1d531
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
20 changes: 17 additions & 3 deletions docs/pages/docs/build-platforms/github-actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,20 @@ jobs:

### NPM: Github Package Registry

If you are publishing to the Github Package Registry you will need to change the `NPM_TOKEN` token secret to match the following:
If you are publishing to the Github Package Registry you will need to change a few things.

1. Modify the node action to use the Github Package Registry and your user scope.

```yml
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
registry-url: "https://npm.pkg.github.com"
scope: "@your-username-scope"
```

2. Use the `GITHUB_TOKEN` as the `NODE_AUTH_TOKEN` to publish to the Github Package Registry.

```yml
- name: Create Release
Expand All @@ -64,7 +77,6 @@ If you are publishing to the Github Package Registry you will need to change the
npx auto shipit
```

This will use your `GITHUB_TOKEN` to publish to the Github Package Registry.
The `NODE_AUTH_TOKEN` variable is required the `.npmrc` that `actions/setup-node@v1` sets up.
If you aren't using `actions/setup-node@v1` replace the variable name `NODE_AUTH_TOKEN` with `NPM_TOKEN` and the `.npmrc` `auto` will handle authentication instead.

Expand All @@ -78,12 +90,14 @@ If you are having problems make sure you have done the following:
### Running With Branch Protection

GitHub actions require a little more setup to use `auto` with branch protection.
We can't use the `GITHUB_TOKEN` to commit to the branch because it does not have high enough permissions.
You will need to create a token with admin access to your repo and modify your build config like the following:

```yml
steps:
- uses: actions/checkout@v2
with:
# Ensure that git uses your token with write access to the repo
# Ensure that git uses your token with admin access to the repo
token: ${{ secrets.GH_TOKEN }}

- name: Prepare repository
Expand Down
5 changes: 4 additions & 1 deletion plugins/npm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,10 @@ export default class NPMPlugin implements IPlugin {
return;
}

auto.checkEnv(this.name, "NPM_TOKEN");
// gh-action + node action uses NODE_AUTH_TOKEN and we should warn about NPM_TOKEN
if (!process.env.NODE_AUTH_TOKEN) {
auto.checkEnv(this.name, "NPM_TOKEN");
}
});

auto.hooks.getAuthor.tapPromise(this.name, async () => {
Expand Down

0 comments on commit 9c1d531

Please sign in to comment.