Skip to content

Commit

Permalink
Merge pull request #1828 from intuit/docss
Browse files Browse the repository at this point in the history
improve GitHub actions docs + remove unnecessary warning
  • Loading branch information
hipstersmoothie committed Feb 24, 2021
2 parents 8b923fb + 3da6de5 commit 218274e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
24 changes: 19 additions & 5 deletions docs/pages/docs/build-platforms/github-actions.mdx
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,8 +77,7 @@ 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.
The `NODE_AUTH_TOKEN` variable is required for 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.

## Troubleshooting
Expand All @@ -78,13 +90,15 @@ 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
token: ${{ secrets.GH_TOKEN }}
# Ensure that git uses your token with admin access to the repo
token: ${{ secrets.ADMIN_TOKEN }}

- name: Prepare repository
# Fetch full git history and tags
Expand Down
5 changes: 4 additions & 1 deletion plugins/npm/src/index.ts
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 218274e

Please sign in to comment.