Repository: vercel/next.js
Pull request: Run front-sync after deployment tests finish 

The front-sync job has been running directly have new versions are published, but deployment tests only run after a release as well. This PR runs the front-sync job after the deployment tests. There is a new input on the workflow the front-sync triggers to immediately close the PR that gets opened in that repo that will get set to true if the tests fail. It is still beneficial to open a PR so we can more easily bisect problematic releases.

See thread for discussion: https://vercel.slack.com/archives/C08V7CU57E1/p1751053430834889

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the PR.
- Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to understand the PR)
- When linking to a Slack thread, you might want to share details of the conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes PACK-4967

Changed files:
filename: .github/workflows/notify_release.yml
patch: @@ -1,83 +0,0 @@
-# A workflow runs when a release is published, dispatches a new event to the vercel/turbo
-# to notify its release. Turbopack, and other integration workflow will subscribe to this event.
-name: Notify new Next.js release
-on:
-  release:
-    types: [published]
-jobs:
-  notify:
-    runs-on: ubuntu-latest
-    if: ${{ github.event_name == 'release' }}
-    steps:
-      - uses: actions/github-script@v7
-        id: notify-new-release
-        with:
-          result-encoding: string
-          retries: 3
-          retry-exempt-status-codes: 400,401
-          # Default github token cannot dispatch events to the remote repo, it should be
-          # a PAT with access to contenst:read&write + metadata:read.
-          github-token: ${{ secrets.TURBOPACK_TEST_TOKEN }}
-          # Note `event_type` and `client_payload` are contract between vercel/turbo,
-          # if these need to be changed both side should be updated accordingly.
-          script: |
-            github.request('POST /repos/{owner}/{repo}/dispatches', {
-              owner: 'vercel',
-              repo: 'turbo',
-              event_type: 'nextjs-release-published',
-              client_payload: {
-                version: context.ref
-              }
-            })
-  front-sync:
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v4
-      - id: nextPackageInfo
-        name: Get `next` package info
-        run: |
-          cd packages/next 
-          {
-            echo 'value<<EOF'
-            cat package.json
-            echo EOF
-          } >> "$GITHUB_OUTPUT"
-      - id: version
-        name: Extract `next` version
-        run: echo 'value=${{ fromJson(steps.nextPackageInfo.outputs.value).version }}' >> "$GITHUB_OUTPUT"
-      - name: Check token
-        run: gh auth status
-        env:
-          GITHUB_TOKEN: ${{ secrets.FRONT_TEST_TOKEN }}
-      - uses: actions/github-script@v7
-        name: Trigger vercel/front sync
-        id: trigger-front-sync
-        with:
-          retries: 3
-          retry-exempt-status-codes: 400,401,404
-          # Default github token cannot dispatch events to the remote repo, it should be
-          # a PAT with Actions write access (https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event)
-          github-token: ${{ secrets.FRONT_TEST_TOKEN }}
-          # Note `workflow_id` and `inputs` are contract between vercel/front,
-          # if these need to be changed both side should be updated accordingly.
-          script: |
-            await github.request(
-              "POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches",
-              {
-                owner: "vercel",
-                repo: "front",
-                workflow_id: "cron-update-next.yml",
-                ref: "main",
-                inputs: {
-                  version: "${{ steps.version.outputs.value }}",
-                },
-              }
-            );
-            // Ideally we'd include a URL to this specific sync.
-            // However, creating a workflow_dispatch event does not produce an ID: https://github.com/orgs/community/discussions/9752
-            console.info(
-              "Sync started in https://github.com/vercel/front/actions/workflows/cron-update-next.yml?query=event%3Aworkflow_dispatch"
-            );
-            console.info(
-              "This may not start a new sync if one is already in progress. Check the logs of the cron-update-next Workflow run."
-            );

filename: .github/workflows/test_e2e_deploy_release.yml
patch: @@ -86,3 +86,73 @@ jobs:
           if [ -d ./test/test-junit-report ]; then
             DD_ENV=ci npx @datadog/datadog-ci@2.23.1 junit upload --tags test.type:deploy --service nextjs ./test/test-junit-report
           fi
+
+  front-sync:
+    needs: test-deploy
+    if: ${{ always() && github.repository_owner == 'vercel' && github.event_name == 'release' }}
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+      - id: nextPackageInfo
+        name: Get `next` package info
+        run: |
+          cd packages/next 
+          {
+            echo 'value<<EOF'
+            cat package.json
+            echo EOF
+          } >> "$GITHUB_OUTPUT"
+      - id: version
+        name: Extract `next` version
+        run: echo 'value=${{ fromJson(steps.nextPackageInfo.outputs.value).version }}' >> "$GITHUB_OUTPUT"
+      - id: test-result
+        name: Set test result variable
+        run: echo 'immediately-close=${{ needs.test-deploy.result != 'success' && 'true' || 'false' }}' >> "$GITHUB_OUTPUT"
+      - name: Check token
+        run: gh auth status
+        env:
+          github-token: ${{ secrets.GH_UPDATE_NEXT_WORKFLOW_TRIGGER }}
+      - uses: actions/github-script@v7
+        name: Trigger vercel/front sync
+        id: trigger-front-sync
+        with:
+          retries: 3
+          retry-exempt-status-codes: 400,401,404
+          # Default github token cannot dispatch events to the remote repo, it should be
+          # a PAT with Actions write access (https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event)
+          github-token: ${{ secrets.GH_UPDATE_NEXT_WORKFLOW_TRIGGER }}
+          # Note `workflow_id` and `inputs` are contract between vercel/front,
+          # if these need to be changed both side should be updated accordingly.
+          script: |
+            const immediatelyClose = '${{ steps.test-result.outputs.immediately-close }}';
+            const inputs = {
+              version: "${{ steps.version.outputs.value }}",
+            };
+
+            if (immediatelyClose === 'true') {
+              inputs['immediately-close'] = 'true';
+            }
+
+            await github.request(
+              "POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches",
+              {
+                owner: "vercel",
+                repo: "front",
+                workflow_id: "cron-update-next.yml",
+                ref: "main",
+                inputs: inputs,
+              }
+            );
+            // Ideally we'd include a URL to this specific sync.
+            // However, creating a workflow_dispatch event does not produce an ID: https://github.com/orgs/community/discussions/9752
+            console.info(
+              "Sync started in https://github.com/vercel/front/actions/workflows/cron-update-next.yml?query=event%3Aworkflow_dispatch"
+            );
+            console.info(
+              "This may not start a new sync if one is already in progress. Check the logs of the cron-update-next Workflow run."
+            );
+            if (immediatelyClose === 'true') {
+              console.info(
+                "Sync triggered with immediately-close=true due to test failure."
+              );
+            }