-
Notifications
You must be signed in to change notification settings - Fork 0
chore: switch canonical to pagent.vercel.app + auto-alias workflow #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| name: Pin pagent.vercel.app to latest production | ||
|
|
||
| # Re-alias pagent.vercel.app to whichever pagent project deployment Vercel | ||
| # has just promoted to production. Required because the bare pagent.vercel.app | ||
| # subdomain is owned by another team's project at the project-domain layer | ||
| # (Vercel rejects adding it as our project's auto-tracking domain), so we | ||
| # can serve from it via deployment aliases but it does NOT auto-update on | ||
| # new prod deploys. This workflow does the re-alias for us. | ||
| # | ||
| # Setup: add a VERCEL_TOKEN secret with team-scope access to the ful team. | ||
| # Without the secret, the workflow no-ops loudly (does not fail). | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: vercel-alias-pagent | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| alias: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| permissions: | ||
| contents: read | ||
| env: | ||
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | ||
| VERCEL_PROJECT_ID: prj_JhOxWsbBLRb1Sdo19Thbz4eHOyj7 | ||
| VERCEL_TEAM_ID: team_zDJQ6yrYdOu79gJBmUIBVYCV | ||
| ALIAS: pagent.vercel.app | ||
| steps: | ||
| - name: Skip if VERCEL_TOKEN is unset | ||
| id: gate | ||
| run: | | ||
| if [ -z "$VERCEL_TOKEN" ]; then | ||
| echo "::warning::VERCEL_TOKEN secret is unset — skipping auto-alias. Add it under Settings → Secrets → Actions to enable." | ||
| echo "skip=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "skip=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Wait for the production deployment to be READY | ||
| if: steps.gate.outputs.skip == 'false' | ||
| id: wait | ||
| run: | | ||
| for i in $(seq 1 30); do | ||
| JSON=$(curl -s -H "Authorization: Bearer $VERCEL_TOKEN" \ | ||
| "https://api.vercel.com/v6/deployments?projectId=$VERCEL_PROJECT_ID&teamId=$VERCEL_TEAM_ID&target=production&limit=1") | ||
| STATE=$(echo "$JSON" | jq -r '.deployments[0].state // "unknown"') | ||
| URL=$(echo "$JSON" | jq -r '.deployments[0].url // ""') | ||
| echo "attempt $i: state=$STATE url=$URL" | ||
| if [ "$STATE" = "READY" ] && [ -n "$URL" ]; then | ||
| echo "url=$URL" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| if [ "$STATE" = "ERROR" ] || [ "$STATE" = "CANCELED" ]; then | ||
| echo "::error::Latest production deployment is $STATE — nothing to alias." | ||
| exit 1 | ||
| fi | ||
| sleep 10 | ||
| done | ||
| echo "::error::Timed out waiting for production deployment to be READY." | ||
| exit 1 | ||
|
|
||
| - name: Install Vercel CLI | ||
| if: steps.gate.outputs.skip == 'false' | ||
| run: npm install -g vercel@latest | ||
|
|
||
| - name: Re-alias $ALIAS to ${{ steps.wait.outputs.url }} | ||
| if: steps.gate.outputs.skip == 'false' | ||
| run: | | ||
| vercel alias set "${{ steps.wait.outputs.url }}" "$ALIAS" \ | ||
| --token "$VERCEL_TOKEN" --scope "$VERCEL_TEAM_ID" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop aliases whichever deployment is currently returned by
target=production&limit=1, but it never verifies that deployment belongs to the commit that triggered this run. On a fastpushtomain, the new Vercel deployment may not exist yet, so the API can return the previous production deployment inREADYstate, causing the job to exit successfully while re-pointingpagent.vercel.appto stale code. Please gate on a deployment field tied to${{ github.sha }}(or wait until that SHA appears) before acceptingREADY.Useful? React with 👍 / 👎.