Skip to content
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

Use "workflow env var" pattern for secrets as env vars #22

Merged
merged 3 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
pull_request:
branches: ['main']

env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -24,5 +27,3 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install-test
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
release:
types: [created]

env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -16,8 +20,6 @@ jobs:
with:
node-version: 20
- run: npm install-test
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

publish-npm:
needs: build
Expand All @@ -30,5 +32,3 @@ jobs:
registry-url: https://registry.npmjs.org/
- run: npm install
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/storybook-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
pull_request:
branches: ['main']

env:
NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -22,16 +26,12 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
- name: Install dependencies
run: npm install
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Wait for Netlify
uses: probablyup/wait-for-netlify-action@v3.4.0
id: waitForDeployment
with:
site_id: ${{ secrets.NETLIFY_SITE_ID }}
env:
NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }}

- name: Run Storybook tests
run: npm run test:storybook
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The GitHub action [npm-publish.yml](.github/workflows/npm-publish.yml) is used t

#### Code linting tests

The GitHub action [node.js.yml](.github/workflows/node.js.yml) is used to run the code linting tests on pull requests and commit pushes into the main branch.
The GitHub action [node.js.yml](.github/workflows/node.js.yml) is used to run the code linting tests on pull requests and commit pushes into the main branch. The action requires the `NPM_TOKEN` secrets to be set.

`npm run test` runs the code linting tests:

Expand All @@ -59,6 +59,7 @@ The GitHub action [storybook-tests.yml](.github/workflows/storybook-tests.yml) i

- `NETLIFY_SITE_ID`
- `NETLIFY_TOKEN`
- `NPM_TOKEN`

These Storybook CI tests can also be run while running Storybook locally:

Expand Down