32
32
setup :
33
33
runs-on : ubuntu-latest
34
34
if : github.repository_owner == 'vercel'
35
+ outputs :
36
+ next-version : ${{ steps.version.outputs.value }}
35
37
steps :
36
38
- name : Setup Node.js
37
39
uses : actions/setup-node@v4
@@ -49,14 +51,27 @@ jobs:
49
51
with :
50
52
fetch-depth : 25
51
53
54
+ - id : nextPackageInfo
55
+ name : Get `next` package info
56
+ run : |
57
+ cd packages/next
58
+ {
59
+ echo 'value<<EOF'
60
+ cat package.json
61
+ echo EOF
62
+ } >> "$GITHUB_OUTPUT"
63
+ - id : version
64
+ name : Extract `next` version
65
+ run : echo 'value=${{ fromJson(steps.nextPackageInfo.outputs.value).version }}' >> "$GITHUB_OUTPUT"
66
+
52
67
- name : Setup test project
53
68
run : |
54
69
pnpm install
55
70
pnpm run build
56
71
node scripts/run-e2e-test-project-reset.mjs
57
72
58
73
test-deploy :
59
- name : test deploy
74
+ name : Run Deploy Tests
60
75
needs : setup
61
76
uses : ./.github/workflows/build_reusable.yml
62
77
secrets : inherit
77
92
if : ${{ always() }}
78
93
79
94
runs-on : ubuntu-latest
80
- name : report test results to datadog
95
+ name : Report test results to datadog
81
96
steps :
82
97
- name : Download test report artifacts
83
98
id : download-test-reports
@@ -93,9 +108,79 @@ jobs:
93
108
DD_ENV=ci npx @datadog/datadog-ci@2.23.1 junit upload --tags test.type:deploy --service nextjs ./test/test-junit-report
94
109
fi
95
110
96
- sync-repositories :
97
- needs : test-deploy
98
- if : ${{ always() && github.repository_owner == 'vercel' && github.event_name == 'release' }}
111
+ create-draft-prs :
112
+ name : Immediately open draft prs
113
+ needs : setup
114
+ if : ${{ github.repository_owner == 'vercel' && github.event_name == 'release' }}
115
+ runs-on : ubuntu-latest
116
+ strategy :
117
+ fail-fast : false
118
+ matrix :
119
+ include :
120
+ - repo : front
121
+ workflow_id : cron-update-next.yml
122
+ - repo : v0
123
+ workflow_id : update-next.yml
124
+ steps :
125
+ - name : Check token
126
+ run : gh auth status
127
+ env :
128
+ GITHUB_TOKEN : ${{ secrets.GH_UPDATE_NEXT_WORKFLOW_TRIGGER }}
129
+ - uses : actions/github-script@v7
130
+ name : Check if target workflow is enabled
131
+ id : check-workflow-enabled
132
+ with :
133
+ retries : 3
134
+ retry-exempt-status-codes : 400,401,403,404,422
135
+ github-token : ${{ secrets.GH_UPDATE_NEXT_WORKFLOW_TRIGGER }}
136
+ result-encoding : string
137
+ script : |
138
+ const response = await github.request(
139
+ "GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}",
140
+ {
141
+ owner: "vercel",
142
+ repo: "${{ matrix.repo }}",
143
+ workflow_id: "${{ matrix.workflow_id }}",
144
+ }
145
+ );
146
+
147
+ const isEnabled = response.data.state === 'active';
148
+ console.info(`Target workflow state: ${response.data.state}`);
149
+ console.info(`Target workflow enabled: ${isEnabled}`);
150
+
151
+ return isEnabled ? 'true' : 'false';
152
+ - uses : actions/github-script@v7
153
+ name : Create draft PR for vercel/${{ matrix.repo }}
154
+ id : create-draft-pr
155
+ if : steps.check-workflow-enabled.outputs.result == 'true'
156
+ with :
157
+ retries : 3
158
+ retry-exempt-status-codes : 400,401,404
159
+ github-token : ${{ secrets.GH_UPDATE_NEXT_WORKFLOW_TRIGGER }}
160
+ result-encoding : string
161
+ script : |
162
+ const inputs = {
163
+ version: "${{ needs.setup.outputs.next-version }}"
164
+ };
165
+
166
+ await github.request(
167
+ "POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches",
168
+ {
169
+ owner: "vercel",
170
+ repo: "${{ matrix.repo }}",
171
+ workflow_id: "${{ matrix.workflow_id }}",
172
+ ref: "main",
173
+ inputs: inputs,
174
+ }
175
+ );
176
+
177
+ console.info(`Draft PR creation triggered for ${{ matrix.repo }}`);
178
+ console.info(`Workflow will create draft PR by default`);
179
+
180
+ update-prs :
181
+ name : Update prs as ready for review
182
+ needs : [test-deploy, create-draft-prs]
183
+ if : ${{ needs.test-deploy.result == 'success' && github.repository_owner == 'vercel' && github.event_name == 'release' }}
99
184
runs-on : ubuntu-latest
100
185
strategy :
101
186
fail-fast : false
@@ -108,22 +193,6 @@ jobs:
108
193
workflow_id : update-next.yml
109
194
workflow_url : https://github.com/vercel/v0/actions/workflows/update-next.yml?query=event%3Aworkflow_dispatch
110
195
steps :
111
- - uses : actions/checkout@v4
112
- - id : nextPackageInfo
113
- name : Get `next` package info
114
- run : |
115
- cd packages/next
116
- {
117
- echo 'value<<EOF'
118
- cat package.json
119
- echo EOF
120
- } >> "$GITHUB_OUTPUT"
121
- - id : version
122
- name : Extract `next` version
123
- run : echo 'value=${{ fromJson(steps.nextPackageInfo.outputs.value).version }}' >> "$GITHUB_OUTPUT"
124
- - id : test-result
125
- name : Set test result variable
126
- run : echo 'immediately-close=${{ needs.test-deploy.result != 'success' && 'true' || 'false' }}' >> "$GITHUB_OUTPUT"
127
196
- name : Check token
128
197
run : gh auth status
129
198
env :
@@ -157,8 +226,8 @@ jobs:
157
226
return 'false';
158
227
}
159
228
- uses : actions/github-script@v7
160
- name : Trigger vercel/${{ matrix.repo }} sync
161
- id : trigger-sync
229
+ name : Mark PR ready for review in vercel/${{ matrix.repo }}
230
+ id : mark-pr-ready
162
231
if : steps.check-workflow-enabled.outputs.result == 'true'
163
232
with :
164
233
retries : 3
@@ -169,15 +238,12 @@ jobs:
169
238
# Note `workflow_id` and `inputs` are contract between vercel/${{ matrix.repo }},
170
239
# if these need to be changed both side should be updated accordingly.
171
240
script : |
172
- const immediatelyClose = '${{ steps.test-result.outputs.immediately-close }}';
173
241
const inputs = {
174
- version: "${{ steps.version.outputs.value }}",
242
+ version: "${{ needs.setup.outputs.next-version }}",
243
+ 'make-ready-for-review': 'true',
244
+ force: 'true'
175
245
};
176
246
177
- if (immediatelyClose === 'true') {
178
- inputs['immediately-close'] = 'true';
179
- }
180
-
181
247
await github.request(
182
248
"POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches",
183
249
{
@@ -188,16 +254,8 @@ jobs:
188
254
inputs: inputs,
189
255
}
190
256
);
191
- // Ideally we'd include a URL to this specific sync.
192
- // However, creating a workflow_dispatch event does not produce an ID: https://github.com/orgs/community/discussions/9752
193
- console.info(
194
- "Sync started in ${{ matrix.workflow_url }}"
195
- );
257
+
258
+ console.info("Tests passed - PR will be marked ready for review");
196
259
console.info(
197
- "This may not start a new sync if one is already in progress. Check the logs of the workflow run. "
260
+ "PR ready-for-review triggered in ${{ matrix.workflow_url }} "
198
261
);
199
- if (immediatelyClose === 'true') {
200
- console.info(
201
- "Sync triggered with immediately-close=true due to test failure."
202
- );
203
- }
0 commit comments