-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ci): add GitHub Actions workflow for sequential CMS and Web deployment #8
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
Open
jhb-dev
wants to merge
19
commits into
main
Choose a base branch
from
test/preview-deployment
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ce42058
feat(ci): add GitHub Actions workflow for deploying CMS and Web appli…
jhb-dev 0d006a7
fix(ci): use Vercel remote build instead of local build
jhb-dev bf43b04
fix(ci): set VERCEL_PROJECT_ID as env variable
jhb-dev 0675d24
fix(ci): remove working-directory, use Vercel project root settings
jhb-dev 6b09e43
refactor(ci): remove unnecessary ready check step
jhb-dev 4528bf4
docs(ci): add description to deploy workflow
jhb-dev 1fd6122
feat(ci): add preview deployments and concurrency control
jhb-dev ba84ea4
test(web): add preview deployment banner and console logs
jhb-dev a570d60
docs(ci): add prerequisites and TODO for bypass secret migration
jhb-dev d98901d
feat(ci): add Vercel inspect links to PR comment
jhb-dev 00e243f
refactor(ci): simplify and speed up deployment workflow
jhb-dev a6e1930
fix(ci): improve URL parsing from Vercel output
jhb-dev 67397ff
refactor(ci): simplify by using vercel stdout directly, remove inspec…
jhb-dev 6e25acc
feat(ci): add change detection and skip tags support
jhb-dev 7cb676b
fix(ci): handle empty CMS_URL and fix PROD_FLAG expression
jhb-dev 844beef
test(cms): add dummy sitemap entry to test CMS-only deployment
jhb-dev b741321
fix(ci): install Vercel CLI globally to avoid npx download
jhb-dev 3ff8c22
feat: add Vercel automation bypass for protected CMS previews
jhb-dev 2d1465e
chore: remove test code from cms and web
jhb-dev 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| # Deployment workflow for the JHB Software website. | ||
| # | ||
| # This workflow deploys the CMS before the Web frontend to ensure the frontend | ||
| # always builds against the latest CMS schema and content. The Web frontend | ||
| # fetches data from the CMS at build time, so the CMS must be deployed first. | ||
| # | ||
| # Production: Triggered on push to main | ||
| # Preview: Triggered on pull requests, uses CMS preview URL for Web build | ||
| # | ||
| # Disable automatic Vercel deployments for both projects to avoid race conditions. | ||
|
|
||
| name: Deploy | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| workflow_dispatch: | ||
| inputs: | ||
| deploy_cms: | ||
| description: 'Deploy CMS' | ||
| required: false | ||
| default: true | ||
| type: boolean | ||
| deploy_web: | ||
| description: 'Deploy Web' | ||
| required: false | ||
| default: true | ||
| type: boolean | ||
| environment: | ||
| description: 'Environment' | ||
| required: false | ||
| default: 'preview' | ||
| type: choice | ||
| options: | ||
| - preview | ||
| - production | ||
|
|
||
| concurrency: | ||
| group: deploy-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | ||
| IS_PRODUCTION: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event.inputs.environment == 'production' }} | ||
|
|
||
| jobs: | ||
| deploy-cms: | ||
| name: Deploy CMS | ||
| runs-on: ubuntu-latest | ||
| if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.deploy_cms == 'true' }} | ||
| outputs: | ||
| deployment_url: ${{ steps.deploy.outputs.deployment_url }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - name: Install Vercel CLI | ||
| run: npm install -g vercel@latest | ||
|
|
||
| - name: Deploy to Vercel (Production) | ||
| id: deploy-prod | ||
| if: ${{ env.IS_PRODUCTION == 'true' }} | ||
| run: | | ||
| DEPLOYMENT_URL=$(vercel deploy --prod --yes --token=${{ secrets.VERCEL_TOKEN }}) | ||
| echo "deployment_url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT | ||
| echo "CMS deployed to: $DEPLOYMENT_URL" | ||
| env: | ||
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_CMS_PROJECT_ID }} | ||
|
|
||
| - name: Deploy to Vercel (Preview) | ||
| id: deploy-preview | ||
| if: ${{ env.IS_PRODUCTION != 'true' }} | ||
| run: | | ||
| DEPLOYMENT_URL=$(vercel deploy --yes --token=${{ secrets.VERCEL_TOKEN }}) | ||
| echo "deployment_url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT | ||
| echo "CMS preview deployed to: $DEPLOYMENT_URL" | ||
| env: | ||
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_CMS_PROJECT_ID }} | ||
|
|
||
| - name: Set deployment URL output | ||
| id: deploy | ||
| run: | | ||
| if [ "${{ env.IS_PRODUCTION }}" == "true" ]; then | ||
| echo "deployment_url=${{ steps.deploy-prod.outputs.deployment_url }}" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "deployment_url=${{ steps.deploy-preview.outputs.deployment_url }}" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| deploy-web: | ||
| name: Deploy Web | ||
| runs-on: ubuntu-latest | ||
| needs: deploy-cms | ||
| if: ${{ always() && (github.event_name != 'workflow_dispatch' || github.event.inputs.deploy_web == 'true') && (needs.deploy-cms.result == 'success' || needs.deploy-cms.result == 'skipped') }} | ||
| outputs: | ||
| deployment_url: ${{ steps.deploy.outputs.deployment_url }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - name: Install Vercel CLI | ||
| run: npm install -g vercel@latest | ||
|
|
||
| - name: Deploy to Vercel (Production) | ||
| id: deploy-prod | ||
| if: ${{ env.IS_PRODUCTION == 'true' }} | ||
| run: | | ||
| DEPLOYMENT_URL=$(vercel deploy --prod --yes --token=${{ secrets.VERCEL_TOKEN }}) | ||
| echo "deployment_url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT | ||
| echo "Web deployed to: $DEPLOYMENT_URL" | ||
| env: | ||
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_WEB_PROJECT_ID }} | ||
|
|
||
| - name: Deploy to Vercel (Preview) | ||
| id: deploy-preview | ||
| if: ${{ env.IS_PRODUCTION != 'true' }} | ||
| run: | | ||
| DEPLOYMENT_URL=$(vercel deploy --yes --token=${{ secrets.VERCEL_TOKEN }} --build-env CMS_URL=${{ needs.deploy-cms.outputs.deployment_url }}) | ||
| echo "deployment_url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT | ||
| echo "Web preview deployed to: $DEPLOYMENT_URL" | ||
| env: | ||
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_WEB_PROJECT_ID }} | ||
|
|
||
| - name: Set deployment URL output | ||
| id: deploy | ||
| run: | | ||
| if [ "${{ env.IS_PRODUCTION }}" == "true" ]; then | ||
| echo "deployment_url=${{ steps.deploy-prod.outputs.deployment_url }}" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "deployment_url=${{ steps.deploy-preview.outputs.deployment_url }}" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Deployment Summary | ||
| run: | | ||
| if [ "${{ env.IS_PRODUCTION }}" == "true" ]; then | ||
| echo "## Production Deployment Complete" >> $GITHUB_STEP_SUMMARY | ||
| else | ||
| echo "## Preview Deployment Complete" >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **CMS**: ${{ needs.deploy-cms.outputs.deployment_url || 'Skipped' }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Web**: ${{ steps.deploy.outputs.deployment_url }}" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| comment-preview: | ||
| name: Comment Preview URLs | ||
| runs-on: ubuntu-latest | ||
| needs: [deploy-cms, deploy-web] | ||
| if: ${{ github.event_name == 'pull_request' && needs.deploy-web.result == 'success' }} | ||
| steps: | ||
| - name: Find existing comment | ||
| uses: peter-evans/find-comment@v3 | ||
| id: find-comment | ||
| with: | ||
| issue-number: ${{ github.event.pull_request.number }} | ||
| comment-author: 'github-actions[bot]' | ||
| body-includes: '## Preview Deployment' | ||
|
|
||
| - name: Create or update comment | ||
| uses: peter-evans/create-or-update-comment@v4 | ||
| with: | ||
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | ||
| issue-number: ${{ github.event.pull_request.number }} | ||
| edit-mode: replace | ||
| body: | | ||
| ## Preview Deployment | ||
|
|
||
| | Project | URL | | ||
| |---------|-----| | ||
| | CMS | ${{ needs.deploy-cms.outputs.deployment_url }} | | ||
| | Web | ${{ needs.deploy-web.outputs.deployment_url }} | | ||
|
|
||
| The Web preview uses the CMS preview URL for content fetching. |
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.
Debug console.log statements will run in production
The
console.logstatements labeled[Preview Test]are unconditional and will execute on every page render in all environments, including production. Unlike theisPreviewDeploymentbanner which is conditional, these logs always run. This appears to be temporary debugging code that was included for testing purposes but will pollute server logs withCMS_URLandVERCEL_ENVvalues on every page load.