Skip to content

Merge pull request #210 from adobecom/MWPW-147600 #223

Merge pull request #210 from adobecom/MWPW-147600

Merge pull request #210 from adobecom/MWPW-147600 #223

Workflow file for this run

name: Merge
on:
push:
branches:
- 'main'
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions: write-all
jobs:
run-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16.13.1
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- run: npm install
- run: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
record-web-vitals:
runs-on: ubuntu-latest
needs: run-release
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get PR Information
id: pr-info
uses: actions/github-script@v6
with:
script: |
const commit = context.sha;
const { owner, repo } = context.repo;
// Find the PR that was merged
const { data: prs } = await github.rest.pulls.list({
owner,
repo,
state: 'closed',
sort: 'updated',
direction: 'desc',
per_page: 100
});
const mergedPR = prs.find(pr => pr.merge_commit_sha === commit);
if (mergedPR) {
core.exportVariable('PR_NUMBER', mergedPR.number);
core.exportVariable('PR_TITLE', mergedPR.title);
core.exportVariable('GITHUB_EVENT_NAME', 'pull_request');
core.exportVariable('GITHUB_EVENT_ACTION', 'closed');
core.exportVariable('GITHUB_PULL_REQUEST_MERGED', 'true');
console.log(`Found PR #${mergedPR.number}: ${mergedPR.title}`);
} else {
console.log('No matching PR found for this commit');
}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16.13.1
cache: 'npm'
- name: Install dependencies
run: |
npm ci
npm install puppeteer web-vitals
- name: Install Chrome dependencies
run: |
sudo apt-get update
sudo apt-get install -y xvfb libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2
- name: Record Web Vitals
run: |
xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24" node scripts/record-web-vitals.js
- name: Commit updated history
run: |
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github.com'
# Stash any changes including untracked files
git stash --include-untracked
# Get latest changes
git pull --rebase origin main
# Reapply our changes
git stash pop
git add web-vitals-history.json
git commit -m "chore: update web vitals history [skip ci]" || echo "No changes to commit"
git push origin main || echo "No changes to push"