Set FontAwesome NPM registry on GitHub Actions

A little while ago, my GitHub actions were failing because of the following error:

error An unexpected error occurred: " Request failed \"401 Unauthorized\"".
info If you think this is a bug, please open a bug report with the information provided in "/home/runner/work/appsignal-status/appsignal-status/yarn-error.log".
info Visit for documentation about this command.
Error: Process completed with exit code 1.

The reason is we use FontAwesome and our action didn't have access to the (private) FontAwesome repo.

In order to fix this we need to make Yarn/NPM aware of this private repo and to do that we'll create a CI environment under the GitHub Repository settings.

Under that CI environment we'll add a FONTAWESOME_NPM_AUTH_TOKEN "Environment secret" (Not variable, secret!) which we can use in the GitHub Actions runner.

To actually expose this secret, we'll have to tell the GitHub Actions runner to use this CI environment, and we'll have to set the NPM config to use the private registry.

For example; this is a linting job that uses the private repository.

    runs-on: ubuntu-latest
    environment: CI # << Set the CI environment
    - uses: actions/checkout@v2
    - name: Install dependencies
      run: |
        npm config set "@fortawesome:registry"
        npm config set '//' "${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }}"
        yarn install
    - name: Run ESLint
      run: yarn lint

GitHub will replace the value with *** on an actual run:

Run npm config set "@fortawesome:registry"
  npm config set "@fortawesome:registry"
  npm config set '//' "***"
  yarn install