Version Packages (#3137) #5046
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Visual Regression Tests | |
on: | |
push: | |
branches: | |
- "main" | |
paths: | |
- "@navikt/**" | |
pull_request: | |
branches: [main, next] | |
paths: | |
- "@navikt/**" | |
- "aksel.nav.no/website/pages/templates/**" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
chromatic: | |
if: ${{ !contains(github.event.pull_request.labels.*.name, 'ignore-chromatic') }} | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
pull-requests: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
cache: yarn | |
- name: set-env for yarn install to @navikt scope | |
shell: bash | |
run: echo "NPM_AUTH_TOKEN=${{ secrets.READER_TOKEN }}" >> $GITHUB_ENV | |
- name: Install dependencies | |
run: yarn | |
- name: Build packages | |
run: yarn boot | |
- name: Chromatic | |
uses: chromaui/action@latest | |
id: chromatic_tests | |
continue-on-error: true | |
with: | |
autoAcceptChanges: "main" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
exitZeroOnChanges: false | |
buildScriptName: "build:storybook-chromatic" | |
onlyChanged: true | |
untraced: "**/package.json|yarn.lock|**/*.md" | |
externals: \@navikt/core/css/**/*.css | |
traceChanged: true | |
env: | |
STORYBOOK_GITHUB_SHA: ${{ github.sha }} | |
- name: replace storybook url | |
if: "!contains(github.event.head_commit.message, '[ci skip]') && github.event_name != 'push'" | |
uses: frabert/replace-string-action@v2 | |
id: storybook_url | |
with: | |
pattern: "(iframe.html)" | |
string: ${{ steps.chromatic_tests.outputs.storybookUrl }} | |
replace-with: "" | |
- name: Get commit sha | |
if: "!contains(github.event.head_commit.message, '[ci skip]') && github.event_name != 'push'" | |
id: vars | |
shell: bash | |
run: | | |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
- name: Find Comment | |
if: "!contains(github.event.head_commit.message, '[ci skip]') && github.event_name != 'push'" | |
uses: peter-evans/find-comment@v2 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: "github-actions[bot]" | |
body-includes: Storybook demo | |
- name: Create or update comment | |
if: steps.chromatic_tests.outcome == 'success' && !contains(github.event.head_commit.message, '[ci skip]') && github.event_name != 'push' | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
## [Storybook demo](${{steps.storybook_url.outputs.replaced}}) | |
[${{ steps.vars.outputs.sha_short }}](https://github.com/navikt/aksel/commit/${{ steps.vars.outputs.sha_short }}) | ${{steps.chromatic_tests.outputs.componentCount}} komponenter | ${{steps.chromatic_tests.outputs.specCount}} stories | |
edit-mode: replace | |
- name: Create or update failed comment | |
if: steps.chromatic_tests.outcome != 'success' && !contains(github.event.head_commit.message, '[ci skip]') && github.event_name != 'push' | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
## [Storybook demo](${{steps.storybook_url.outputs.replaced}}) | |
### [Endringer til review](${{steps.chromatic_tests.outputs.url}}): ${{steps.chromatic_tests.outputs.changeCount}} | |
[${{ steps.vars.outputs.sha_short }}](https://github.com/navikt/aksel/commit/${{ steps.vars.outputs.sha_short }}) | ${{steps.chromatic_tests.outputs.componentCount}} komponenter | ${{steps.chromatic_tests.outputs.specCount}} stories | |
edit-mode: replace |