Skip to content

Update Fixtures From Google Docs #90

Update Fixtures From Google Docs

Update Fixtures From Google Docs #90

on:
workflow_dispatch: {}
schedule:
- cron: '0 17 * * 2' # Noon Pacific on Tuesdays
name: Update Fixtures From Google Docs
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
- name: Install dependencies
run: npm ci
- name: Install browsers
run: npx playwright install chromium
- name: Download Fixtures
run: npm run download-fixtures
# Check whether the fixtures changed.
# The create-pull-request action automatically detects changes, but we
# have an issue where the "*.export.html" fixtures erroneously change
# even when the change is not meaningful. The other ones are stable,
# though, so we use them as an indicator about whether there were changes
# worth committing.
- id: detect_updates
run: |
echo 'Git changes:'
if git status -s | grep --invert '^ M test/fixtures/.*\.export\.html'; then
echo 'Copy fixtures were changed'
echo 'copy_fixtures_changed=true' >> "${GITHUB_OUTPUT}"
else
echo 'Copy fixtures not changed'
echo 'copy_fixtures_changed=' >> "${GITHUB_OUTPUT}"
fi
- name: Generate commit/PR token
if: ${{ steps.detect_updates.outputs.copy_fixtures_changed == 'true' }}
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.FIXTURE_PR_APP_ID }}
private-key: ${{ secrets.FIXTURE_PR_APP_PRIVATE_KEY }}
- name: Create PR
if: ${{ steps.detect_updates.outputs.copy_fixtures_changed == 'true' }}
uses: peter-evans/create-pull-request@v7
with:
token: ${{ steps.generate-token.outputs.token }}
sign-commits: true
branch: 'auto/fixture-update'
delete-branch: true
commit-message: 'Automated fixture update from Google Docs'
title: 'Update Fixtures'
body: >
The clipboard data and/or exported HTML from
[our fixtures in Google Docs](https://drive.google.com/drive/folders/1E2hV-TBLoYBF5ma-z2KpkxLncSnP9zg5)
has changed. This updates the fixtures files in the repo to match the actual Google Docs.
*Generated by running `npm run download-fixtures` and committed via the
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action.*