[Actions] ⚡ Optimize workflows #6094
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: | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
pull-requests: write | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup project | |
uses: ./.github/actions/setup | |
with: | |
npm_auth_token: ${{ secrets.READER_TOKEN }} | |
- name: Chromatic | |
uses: chromaui/action@latest | |
id: chromatic_tests | |
continue-on-error: false | |
with: | |
autoAcceptChanges: "main" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
exitZeroOnChanges: true | |
buildScriptName: "build:storybook-chromatic" | |
onlyChanged: true | |
untraced: "**/package.json|yarn.lock|**/*.md" | |
externals: "**/core/css/*.css|**/core/css/baseline/*.css|**/core/css/form/*.css|**/core/css/primitives/*.css" | |
traceChanged: true | |
env: | |
STORYBOOK_GITHUB_SHA: ${{ github.sha }} | |
- name: Get commit sha | |
if: github.event_name != 'push' && !contains(github.event.head_commit.message, '[ci skip]') | |
id: vars | |
shell: bash | |
run: | | |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
- name: Find Comment | |
if: github.event_name != 'push' && !contains(github.event.head_commit.message, '[ci skip]') | |
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: github.event_name != 'push' && !contains(github.event.head_commit.message, '[ci skip]') | |
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.chromatic_tests.outputs.storybookUrl}}) / [Chromatic](${{steps.chromatic_tests.outputs.url}}) | |
${{ steps.chromatic_tests.outputs.changeCount > 0 && format('### 📝 Changes to review: {0}', steps.chromatic_tests.outputs.changeCount) || '' }} | |
${{ steps.chromatic_tests.outputs.errorCount > 0 && format('### ❌ Stories with errors: {0}', steps.chromatic_tests.outputs.errorCount) || '' }} | |
${{ steps.chromatic_tests.outputs.interactionTestFailuresCount > 0 && format('### ❌ Failed interaction tests: {0}', steps.chromatic_tests.outputs.interactionTestFailuresCount) || '' }} | |
[${{ steps.vars.outputs.sha_short }}](https://github.com/navikt/aksel/commit/${{ steps.vars.outputs.sha_short }}) | ${{steps.chromatic_tests.outputs.componentCount}} components | ${{steps.chromatic_tests.outputs.specCount}} stories | |
edit-mode: replace |