Skip to content

Commit 67295a9

Browse files
authored
Merge pull request #147 from argos-ci/storybook-quickstart-gha-file
feat(storybook): add github actions file content
2 parents 4f9a013 + 1046bb9 commit 67295a9

File tree

1 file changed

+39
-21
lines changed

1 file changed

+39
-21
lines changed

docs/quickstart/storybook.mdx

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,47 @@ It will capture screenshots of your stories in `./screenshots` directory.
7777

7878
## 4. Setup CI to run tests and upload screenshots
7979

80-
First build your Storybook:
81-
82-
```sh
83-
npm run build-storybook
80+
Below is a complete GitHub Actions workflow to build your Storybook, run tests, capture screenshots, and upload them to Argos.
81+
If you use another CI provider, adapt the steps accordingly.
82+
83+
```yml title=".github/workflows/storybook-test.yml"
84+
name: Storybook Test
85+
permissions: {}
86+
87+
on:
88+
push:
89+
branches: [main, master]
90+
pull_request:
91+
branches: [main, master]
92+
93+
jobs:
94+
test:
95+
runs-on: ubuntu-latest
96+
timeout-minutes: 30
97+
steps:
98+
- uses: actions/checkout@v4
99+
- uses: actions/setup-node@v4
100+
101+
- name: Install dependencies
102+
run: npm ci
103+
104+
- name: Build Storybook
105+
run: npm run build-storybook
106+
107+
- name: Install Playwright dependencies
108+
run: npx playwright install --with-deps chromium
109+
110+
- name: Run Storybook tests and capture screenshots
111+
run: |
112+
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
113+
"npx http-server ./storybook-static --port 6006 --silent" \
114+
"npx wait-on tcp:127.0.0.1:6006 && npm run test-storybook"
115+
116+
- name: Upload screenshots to Argos
117+
# 👇 Replace `<ARGOS_TOKEN>` with your project token, available in your Argos project settings.
118+
run: npm exec -- argos upload --token <ARGOS_TOKEN> ./screenshots
84119
```
85120
86-
Then serve your Storybook and run tests:
87-
88-
```sh
89-
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
90-
"npx http-server ./storybook-static --port 6006 --silent" \
91-
"npx wait-on tcp:127.0.0.1:6006 && npm run test-storybook"
92-
```
93-
94-
Finally upload screenshots to Argos:
95-
96-
```sh
97-
npm exec -- argos upload --token <ARGOS_TOKEN> ./screenshots
98-
```
99-
100-
**Note:** The value of `ARGOS_TOKEN` is available in your project settings.
101-
102121
To learn how to run tests on a deployed Storybook, refer to the [Storybook test runner documentation](https://storybook.js.org/docs/writing-tests/test-runner#set-up-ci-to-run-tests).
103122
104123
<Congratulation />
@@ -113,4 +132,3 @@ To learn how to run tests on a deployed Storybook, refer to the [Storybook test
113132
---
114133
115134
<HelpSection />
116-
```

0 commit comments

Comments
 (0)