Skip to content

Structure updates and internal documentation improvements #193

Structure updates and internal documentation improvements

Structure updates and internal documentation improvements #193

# When the comment with the text "/update-snapshots" is added to a PR rebuild
# all the visual snapshots for playwright tests and push them to the PR branch
name: Update Visual Snapshots
on:
# Run any time any issue/PR has a new comment
issue_comment:
types: [created]
jobs:
slash_command:
name: slash command
# This job will only run if the comment was on a pull requests and matches the slash command
if: ${{ github.event.issue.pull_request && github.event.comment.body == '/update-snapshots'}}
# Common with standard build
timeout-minutes: 60
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./inst/editor
steps:
# Checkout with personal TOKEN
# and hop on the PR branch
- uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.GH_ACTION_TOKEN }}
- name: Get Branch
id: getbranch
run: |
branch=$(\
curl \
-H 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
https://github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} \
| jq -r '.head.ref')
echo "::set-output name=branch::$branch"
- name: Fetch Branch
run: git fetch
- name: Checkout Branch
run: git checkout ${{ steps.getbranch.outputs.branch }}
# Continue with standard build
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18
cache: "yarn"
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
- name: Install Playwright Browsers
run: npx playwright install --with-deps
# Update the snapshots
- name: Update snapshots
run: yarn update-visual-snapshots
# Run build to fix the environment variables
- name: Rebuild main bundle
run: yarn build
# Commit the changes
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update Snapshots