Repository navigation
163 lines (140 loc) · 5.86 KB
/
Copy pathsync-upstream.yml
File metadata and controls
163 lines (140 loc) · 5.86 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Sync Upstream Firefox Releases
on:
workflow_dispatch:
inputs:
release_candidate:
description: "Set to true to sync release candidates"
required: false
type: boolean
default: false
workflow_call:
inputs:
release_candidate:
description: "Set to true to sync release candidates"
required: false
type: boolean
default: false
permissions:
contents: write
jobs:
check_candidates:
name: Sync Upstream
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Check if upstream branch already exists
id: check-upstream-branch
run: |
if git ls-remote --heads origin chore/upstream-sync | grep -sw "refs/heads/chore/upstream-sync" > /dev/null; then
echo "branch_exists=true" >> $GITHUB_OUTPUT
else
echo "branch_exists=false" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
uses: actions/setup-node@v4
if: steps.check-upstream-branch.outputs.branch_exists == 'false'
with:
node-version-file: ".nvmrc"
cache: npm
- name: Install dependencies
if: steps.check-upstream-branch.outputs.branch_exists == 'false'
run: npm ci
- name: Install dependencies
if: steps.check-upstream-branch.outputs.branch_exists == 'false'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Setup surfer CI
if: steps.check-upstream-branch.outputs.branch_exists == 'false'
run: |
if [ "${{ github.event.inputs.release_candidate }}" = "false" ]; then
npm run surfer -- ci --brand release
fi
- name: Restore Surfer engine cache
id: surfer-engine-cache
uses: actions/cache@v5
with:
path: .surfer/engine/
key: surfer-engine-${{ hashFiles('surfer.json') }}
- name: Download Firefox and dependencies
if: steps.check-upstream-branch.outputs.branch_exists == 'false'
run: npm run download
- name: Sync Upstream Releases
if: steps.check-upstream-branch.outputs.branch_exists == 'false'
run: |
if [ "${{ github.event.inputs.release_candidate }}" = "true" ]; then
npm run sync:rc
else
npm run sync
fi
- name: Install requirements
run: pip3 install -r requirements.txt
- name: Check if any files changed
id: git-check
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "files_changed=true" >> $GITHUB_OUTPUT
else
echo "files_changed=false" >> $GITHUB_OUTPUT
fi
- name: Get Firefox Version
id: build-data
if: steps.git-check.outputs.files_changed == 'true'
run: |
if [ "${{ github.event.inputs.release_candidate }}" = "true" ]; then
VERSION=$(node -pe "require('./surfer.json').version.candidate")
else
VERSION=$(node -pe "require('./surfer.json').version.version")
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create tracking issue
id: sync-issue
if: steps.git-check.outputs.files_changed == 'true'
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.DEPLOY_KEY }}
TITLE: "Sync upstream Firefox to version `${{ steps.build-data.outputs.version }}`"
run: |
NUMBER=$(gh issue list --repo "$GITHUB_REPOSITORY" --state all --limit 100 \
--search 'Sync upstream Firefox to version in:title' --json number,title \
| jq -r --arg title "$TITLE" 'map(select(.title == $title)) | first | .number // empty')
if [ -z "$NUMBER" ]; then
NUMBER=$(gh issue create --repo "$GITHUB_REPOSITORY" --title "$TITLE" --body "" \
| grep -oE '[0-9]+$')
else
echo "Reusing existing issue #$NUMBER"
fi
echo "number=$NUMBER" >> $GITHUB_OUTPUT
- name: Import external patches
if: steps.git-check.outputs.files_changed == 'true'
run: python3 scripts/update_external_patches.py || true
- name: Check if patches got applied
if: steps.git-check.outputs.files_changed == 'true'
id: check-patches
continue-on-error: true
run: |
echo "Checking if patches apply cleanly..."
npm run import
- name: Import external tests
if: steps.git-check.outputs.files_changed == 'true'
run: python3 scripts/import_external_tests.py || true
- name: Create pull request
uses: peter-evans/create-pull-request@v7
if: steps.git-check.outputs.files_changed == 'true'
env:
GIT_TRACE: 1
GIT_CURL_VERBOSE: 1
with:
token: ${{ secrets.DEPLOY_KEY }}
commit-message: "chore: Sync upstream to `Firefox ${{ steps.build-data.outputs.version }}`"
branch: "chore/upstream-sync"
title: "${{ steps.sync-issue.outputs.number && format('gh-{0}', steps.sync-issue.outputs.number) || 'no-bug' }}: Sync upstream Firefox to version `${{ steps.build-data.outputs.version }}`"
body: |
This PR syncs the upstream Firefox to version ${{ steps.build-data.outputs.version }}.
* ${{ steps.check-patches.outcome == 'failure' && '⚠️ Some patches did not apply cleanly. Please review them carefully.' || '✅ All patches applied cleanly.' }}
${{ steps.sync-issue.outputs.number && format('Fixes https://github.com/{0}/issues/{1}', github.repository, steps.sync-issue.outputs.number) || '' }}
@${{ github.actor }} please review and merge this PR.
base: dev
git-token: ${{ secrets.DEPLOY_KEY }}
delete-branch: true