-
Notifications
You must be signed in to change notification settings - Fork 12
99 lines (88 loc) · 3.17 KB
/
merge.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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"