Skip to content

Commit

Permalink
Merge pull request #6619 from guardian/jc/apps-chromatic-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
joecowton1 committed Dec 2, 2022
2 parents c80eac8 + 1cca6e1 commit eb9df30
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 19 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/ar-chromatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: AR Chromatic 👓

on:
push:
branches: [main]
pull_request:

jobs:
chromatic:
name: Chromatic
runs-on: ubuntu-latest
steps:
- name: Checkout - On Pull Request
uses: actions/checkout@v3
if: ${{ github.event_name == 'pull_request'}}
with:
fetch-depth: 0
# By default the pull_request event will run on a ephermeral merge commit which simulates a merge between the pull request
# and the target branch. This can cause issues with Chromatic https://www.chromatic.com/docs/turbosnap#github-pullrequest-triggers
# Hopefully by checking out the HEAD commit of a PR instead of the merge commit we can avoid some of those issues.
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout - On Push Event
uses: actions/checkout@v3
if: ${{ github.event_name == 'push'}}
with:
fetch-depth: 0

- uses: guardian/actions-setup-node@main

# Cache npm dependencies using https://github.com/bahmutov/npm-install
# Root yarn installs all workspaces (root, common, dotcom)
- uses: bahmutov/npm-install@v1

- name: Chromatic - Apps Rendering Non Dependency PR / main
uses: chromaui/action@v1
if: ${{ github.event_name == 'push' || (!contains(github.event.pull_request.labels.*.name, 'dependencies') && github.event.pull_request.user.login != 'dependabot')}}
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN__APPS_RENDERING }}
token: ${{ secrets.GITHUB_TOKEN }}
untraced: '**/(package**.json|yarn.lock)'
exitOnceUploaded: true
onlyChanged: '!(main)' # only turbosnap on non-main branches
workingDir: apps-rendering

- name: Chromatic - Apps Rendering Dependency PR
uses: chromaui/action@v1
if: ${{ github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'dependencies') || github.event.pull_request.user.login == 'dependabot') }}
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN__APPS_RENDERING }}
token: ${{ secrets.GITHUB_TOKEN }}
autoAcceptChanges: main
workingDir: apps-rendering
51 changes: 51 additions & 0 deletions .github/workflows/cr-chromatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CR Chromatic 👓

on:
push:
branches: [main]
pull_request:

jobs:
chromatic:
name: Chromatic
runs-on: ubuntu-latest
steps:
- name: Checkout - On Pull Request
uses: actions/checkout@v3
if: ${{ github.event_name == 'pull_request'}}
with:
fetch-depth: 0
# By default the pull_request event will run on a ephermeral merge commit which simulates a merge between the pull request
# and the target branch. This can cause issues with Chromatic https://www.chromatic.com/docs/turbosnap#github-pullrequest-triggers
# Hopefully by checking out the HEAD commit of a PR instead of the merge commit we can avoid some of those issues.
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout - On Push Event
uses: actions/checkout@v3
if: ${{ github.event_name == 'push'}}
with:
fetch-depth: 0

- uses: guardian/actions-setup-node@main

# Cache npm dependencies using https://github.com/bahmutov/npm-install
# Root yarn installs all workspaces (root, common, dotcom)
- uses: bahmutov/npm-install@v1

- name: Chromatic - Common Rendering Non Dependency PR / main
uses: chromaui/action@v1
if: ${{ github.event_name == 'push' || (!contains(github.event.pull_request.labels.*.name, 'dependencies') && github.event.pull_request.user.login != 'dependabot')}}
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN__COMMON_RENDERING }}
token: ${{ secrets.GITHUB_TOKEN }}
workingDir: common-rendering
exitOnceUploaded: true
onlyChanged: '!(main)' # only turbosnap on non-main branches

- name: Chromatic - Common Rendering Dependency PR
uses: chromaui/action@v1
if: ${{ github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'dependencies') || github.event.pull_request.user.login == 'dependabot') }}
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN__COMMON_RENDERING }}
token: ${{ secrets.GITHUB_TOKEN }}
autoAcceptChanges: main
workingDir: common-rendering
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Chromatic 👓
name: DCR Chromatic 👓

on:
push:
Expand Down Expand Up @@ -31,24 +31,6 @@ jobs:
# Root yarn installs all workspaces (root, common, dotcom)
- uses: bahmutov/npm-install@v1

- name: Chromatic - Apps Rendering
uses: chromaui/action@v1
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN__APPS_RENDERING }}
token: ${{ secrets.GITHUB_TOKEN }}
workingDir: apps-rendering
exitOnceUploaded: true
onlyChanged: '!(main)' # only turbosnap on non-main branches

- name: Chromatic - Common Rendering
uses: chromaui/action@v1
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN__COMMON_RENDERING }}
token: ${{ secrets.GITHUB_TOKEN }}
workingDir: common-rendering
exitOnceUploaded: true
onlyChanged: '!(main)' # only turbosnap on non-main branches

- name: Chromatic - DCR Non Dependency PR / main
uses: chromaui/action@v1
if: ${{ github.event_name == 'push' || (!contains(github.event.pull_request.labels.*.name, 'dependencies') && github.event.pull_request.user.login != 'dependabot')}}
Expand Down

0 comments on commit eb9df30

Please sign in to comment.