Skip to content

Commit

Permalink
Merge pull request #3028 from alphagov/percy-secret-permissions
Browse files Browse the repository at this point in the history
Skip “Percy screenshots” when secrets are unavailable on forks
  • Loading branch information
colinrotherham committed Nov 21, 2022
2 parents a5c3b32 + 7a81c8c commit 2bb03d5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 20 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/screenshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Percy screenshots

on:
workflow_call:
workflow_dispatch:

concurrency:
group: screenshots-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
screenshots:
name: Send screenshots
runs-on: ubuntu-latest

env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
PORT: 8888

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install dependencies
uses: ./.github/workflows/actions/install-node

- name: Build
uses: ./.github/workflows/actions/build

- name: Start review application
run: npm run serve &

- name: Send screenshots to Percy
run: npx percy exec -- npm run test:screenshots
27 changes: 7 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,26 +162,13 @@ jobs:
run: ${{ matrix.run }}

regression:
name: Send screenshots to Percy
runs-on: ubuntu-latest
name: Percy
needs: [install, build]

env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
PORT: 8888

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Restore dependencies
uses: ./.github/workflows/actions/install-node

- name: Restore build
uses: ./.github/workflows/actions/build

- name: Start review application
run: npm run serve &
# Run existing "Percy screenshots" workflow
# (after install and build have been cached)
uses: ./.github/workflows/screenshots.yml
secrets: inherit

- name: Send screenshots to Percy
run: npx percy exec -- npm run test:screenshots
# Skip when secrets are unavailable on forks
if: ${{ github.repository_owner == 'alphagov' }}

0 comments on commit 2bb03d5

Please sign in to comment.