diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index 58e14f0e..7f1985c5 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -1,11 +1,52 @@ name: "Chromatic" -on: push +on: + push: + branches: + - develop + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-chromatic + cancel-in-progress: true + +permissions: + actions: write + contents: read jobs: + changed-files: + runs-on: ubuntu-latest + name: changed-files + outputs: + all_changed_files: ${{ steps.changed-files.outputs.all_changed_files }} + any_changed: ${{ steps.changed-files.outputs.any_changed }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v44 + with: + files: | + webapp/src/app/** + webapp/.storybook/** + - name: List all changed files + env: + ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + ANY_CHANGED: ${{ steps.changed-files.outputs.any_changed }} + run: | + for file in ${ALL_CHANGED_FILES}; do + echo "$file was changed" + echo Did any files change: ${ANY_CHANGED} + done + chromatic: name: Run Chromatic runs-on: ubuntu-latest + needs: [changed-files] + if: ${{ needs.changed-files.outputs.any_changed == 'true' }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -13,19 +54,22 @@ jobs: fetch-depth: 0 - uses: actions/setup-node@v4 with: + cache: npm + cache-dependency-path: ./package.json node-version: 22 - name: Install dependencies - # ⚠️ See your package manager's documentation for the correct command to install dependencies in a CI environment. working-directory: ./webapp - run: npm ci + run: npm install - name: Run Chromatic id: chromatic uses: chromaui/action@latest with: - # ⚠️ Make sure to configure a `CHROMATIC_PROJECT_TOKEN` repository secret projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} autoAcceptChanges: "develop" workingDir: webapp + exitZeroOnChanges: true + exitOnceUploaded: true + onlyChanged: true skip: "dependabot/**" - name: Publish Summary run: echo -e "| Results | |\n| --- | --- |\n| Build Results | ${{ steps.chromatic.outputs.buildUrl }} |\n| Storybook Preview | ${{ steps.chromatic.outputs.storybookUrl }} |\n| Component Count | ${{steps.chromatic.outputs.componentCount}} |" >> $GITHUB_STEP_SUMMARY \ No newline at end of file