Skip to content

Deployment Actions #40117

Deployment Actions

Deployment Actions #40117

name: Deployment Actions
on: deployment_status
env:
PUPPETEER_DOWNLOAD_PATH: /home/runner/.npm/chromium
jobs:
dump_github_event:
uses: ./.github/workflows/dump_event.yml
# Do a find-and-replace to add a link to the deployment to the PR body
update_pr_description:
# Only want to run on success, otherwise it might be "pending", or "failure".
# Filter out storybook deployments and temporarily Netlify deployments
if: ${{ (github.event.deployment.ref != 'main') && (github.event.deployment_status.state == 'success') && !startsWith(github.event.deployment_status.environment, 'storybook')}}
name: Add deploy URL to PR description
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Note we can't use caching here, because caching needs GITHUB_REF to be defined,
# and Vercel deployment_status events set deployment.ref to the SHA, not the triggering
# branch or pull request.
# https://github.com/actions/cache/issues/319
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
- run: npm ci
- uses: ./.github/actions/ref_from_sha
name: Get PR Ref from SHA
id: ref_from_sha
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: mcky/find-and-replace-pull-request-body@v1.1.6-mcky
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
prNumber: ${{ steps.ref_from_sha.outputs.pr_number }}
find: "{owa_deployment_url}"
replace: ${{ github.event.deployment_status.environment_url }}
# Warm the caches on the test URLs
# warm_caches:
# # Only want to run on success, otherwise it might be "pending", or "failure".
# # Filter out storybook deployments and temporarily Netlify deployments
# if: ${{ (github.event.deployment_status.state == 'success') && !startsWith(github.event.deployment_status.environment, 'storybook')}}
# name: Warm Caches
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Use Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 20.x
# cache: "npm"
# - run: npm ci
# - name: Warm the Cache
# run: node ./scripts/build/warm_cache.js
# env:
# BASE_URL: ${{ github.event.deployment_status.environment_url }}
# CF_ACCESS_CLIENT_ID: ${{ secrets.CF_ACCESS_CLIENT_ID }}
# CF_ACCESS_CLIENT_SECRET: ${{ secrets.CF_ACCESS_CLIENT_SECRET }}
# Run Pa11yCI against a deployment.
pa11y:
# needs: warm_caches
# Only want to run on success, otherwise it might be "pending", or "failure".
# Filter out storybook deployments and temporarily Netlify deployments
if: ${{ (github.event.deployment_status.state == 'success') && !startsWith(github.event.deployment_status.environment, 'storybook')}}
name: Pa11y
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
# Install.
- run: npm ci
- name: Log out URL
run: echo "${{ github.event.deployment_status.environment_url }}"
# Run pa11y
- name: Pa11y CI
id: run_pa11y
run: npm run pa11y
env:
BASE_URL: ${{ github.event.deployment_status.environment_url }}
CF_ACCESS_CLIENT_ID: ${{ secrets.CF_ACCESS_CLIENT_ID }}
CF_ACCESS_CLIENT_SECRET: ${{ secrets.CF_ACCESS_CLIENT_SECRET }}
# Set a custom status because there may be more than one deployment_status
# event due to alternatively themed deployments, and multiple runs of this
# workflow will overwrite each other in the PR checks UI, but custom statuses
# will remain
- uses: ./.github/actions/custom_statuses
name: Set Pa11y check result
if: ${{ always() }}
with:
description: Pa11y (${{github.event.deployment_status.environment}})
state: ${{ steps.run_pa11y.outcome }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# Run Percy visual regression tests against preview and production deployments.
percy:
# needs: warm_caches
# Only want to run on success, otherwise it might be "pending", or "failure".
# Filter out storybook deployments and temporarily Netlify deployments
if: ${{ (github.event.deployment_status.state == 'success') && !startsWith(github.event.deployment_status.environment, 'storybook')}}
name: Percy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
- run: npm ci
- name: Log out URL
run: echo "${{ github.event.deployment_status.environment_url }}"
- uses: ./.github/actions/ref_from_sha
name: Get PR Ref from SHA
id: ref_from_sha
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: print branch name and PR number from sha
run: |
echo "${{ steps.ref_from_sha.outputs.branch_name }}"
echo "${{ steps.ref_from_sha.outputs.pr_number }}"
- uses: ./.github/actions/percy_snapshots
name: run percy
id: run_percy
with:
base_url: ${{ github.event.deployment_status.environment_url }}
branch_name: ${{ steps.ref_from_sha.outputs.branch_name }}
pr_number: ${{ steps.ref_from_sha.outputs.pr_number }}
percy_token: ${{ secrets.PERCY_TOKEN }}
env:
CF_ACCESS_CLIENT_ID: ${{ secrets.CF_ACCESS_CLIENT_ID }}
CF_ACCESS_CLIENT_SECRET: ${{ secrets.CF_ACCESS_CLIENT_SECRET }}
PERCY_PAGE_LOAD_TIMEOUT: 60000
# Set custom status so results preserved between multiple
# deployment events from same commit
- uses: ./.github/actions/custom_statuses
name: Set Percy check result
if: ${{ always() }}
with:
description: Percy (${{github.event.deployment_status.environment}})
state: ${{ steps.run_percy.outcome }}
github_token: ${{ secrets.GITHUB_TOKEN }}