@@ -11,6 +11,7 @@ The CI workflow (`.github/workflows/build-and-test.yml`) is configured with thre
11113 . ** deploy-to-vercel** - Deploys to Vercel production only after deployment gate succeeds
1212
1313This ensures Vercel deployments only occur when:
14+
1415- Push is to the ` main ` branch
1516- All tests pass
1617- Build succeeds
@@ -70,17 +71,33 @@ The `.vercel/project.json` file created by `vercel link` will contain both `proj
70713 . Click ** New repository secret**
71724 . Add each of these three secrets:
7273
73- | Secret Name | Value |
74- | -------------| -------|
75- | ` VERCEL_TOKEN ` | Token from step 1.1 |
76- | ` VERCEL_PROJECT_ID ` | Project ID from step 1.2 |
77- | ` VERCEL_ORG_ID ` | Organization ID from step 1.3 |
74+ - ** Name** : Exact name from the list above (case-sensitive)
75+ - ** Value** : The actual secret value from your local ` .env ` file
76+ - Click ** Add secret**
7877
7978** Important:**
79+
8080- Secret names must match exactly (case-sensitive)
8181- Values should be pasted as-is, no quotes or extra whitespace
8282- After saving, you cannot view the values again (only update them)
8383
84+ ### GitHub Security Features
85+
86+ GitHub Actions automatically:
87+
88+ - ✅ ** Masks secret values** in all log output
89+ - ✅ ** Prevents secrets from being printed** to console
90+ - ✅ ** Blocks secret exposure** in pull requests from forks
91+ - ✅ ** Encrypts secrets** at rest and in transit
92+
93+ ** Example of Masked Output**
94+
95+ If a secret contains ` abc123xyz ` , GitHub will show:
96+
97+ ``` bash
98+ ***
99+ ```
100+
84101## Step 3: Configure Vercel to Prevent Auto-Deploy
85102
86103You must disable Vercel's automatic GitHub deployments to rely exclusively on the GitHub Action.
@@ -131,6 +148,7 @@ If you want Vercel to remain connected but wait for CI:
131148
1321493 . Go to GitHub ** Actions** tab
1331504 . Watch the workflow run:
151+
134152 - ` build-and-test ` should run first (lint, tests, build, E2E)
135153 - ` deployment-ready ` should run after tests pass
136154 - ` deploy-to-vercel ` should run last and deploy to Vercel production
@@ -144,27 +162,47 @@ If you want Vercel to remain connected but wait for CI:
144162### Troubleshooting
145163
146164** If deployment fails with authentication error:**
165+
147166- Verify secrets are set correctly in GitHub (names match exactly)
148167- Check token hasn't expired
149168- Ensure token has correct scope/permissions
150169
151170** If deployment doesn't trigger:**
171+
152172- Verify push is to ` main ` branch
153173- Check that ` deployment-ready ` job succeeded
154174- Look at GitHub Actions logs for errors
155175
156176** If tests pass but deployment skipped:**
177+
157178- Check the ` if: github.ref == 'refs/heads/main' && success() ` condition
158179- Ensure previous jobs succeeded (not just "completed")
159180
160181** If Vercel still auto-deploys:**
182+
161183- Double-check Step 3 settings in Vercel dashboard
162184- May need to disconnect and reconnect Git integration
163185- Contact Vercel support if setting persists
164186
165- ## Step 5: Optional - Set Up Branch Protection
187+ ** "Context access might be invalid" warnings**
188+
189+ These YAML lint warnings appear before secrets are added to GitHub. They will disappear once you configure the secrets in your repository settings.
190+
191+ ** Build fails with "environment variable is not set"**
192+
193+ 1 . Verify the secret is added in GitHub Settings
194+ 2 . Check the secret name matches exactly (case-sensitive)
195+ 3 . Ensure the workflow file references the secret correctly: ` ${{ secrets.SECRET_NAME }} `
196+
197+ ** Secret not available in job**
198+
199+ - Secrets are not passed to workflows triggered by forks
200+ - Check that the secret is configured at the repository level (not environment level)
201+ - Verify the job has access to secrets (jobs inherit by default)
202+
203+ ## Step 5: Set Up Branch Protection
166204
167- For additional safety, configure branch protection on ` main ` :
205+ Configure branch protection on ` main ` :
168206
1692071 . Go to GitHub ** Settings** → ** Branches**
1702082 . Add branch protection rule for ` main `
@@ -177,6 +215,7 @@ For additional safety, configure branch protection on `main`:
1772154 . Save changes
178216
179217This ensures:
218+
180219- No direct pushes to ` main ` (requires PR)
181220- CI must pass before merge
182221- Forces code review workflow
@@ -201,23 +240,7 @@ Tokens should be rotated periodically (recommend yearly):
201240### Updating the Workflow
202241
203242If you modify ` .github/workflows/build-and-test.yml ` :
243+
204244- Ensure job dependencies remain correct (` needs: ... ` )
205245- Keep the ` if: github.ref == 'refs/heads/main' ` conditions
206246- Test in a feature branch first before merging to ` main `
207-
208- ## Security Best Practices
209-
210- 1 . ** Never commit secrets to the repository** (use GitHub Secrets only)
211- 2 . ** Use organization/team tokens** rather than personal tokens when possible
212- 3 . ** Set token expiration** and rotate regularly
213- 4 . ** Limit token scope** to only the necessary permissions
214- 5 . ** Use branch protection** to prevent accidental deployments
215- 6 . ** Review GitHub Actions logs** regularly for suspicious activity
216- 7 . ** Enable 2FA** on both GitHub and Vercel accounts
217-
218- ## Resources
219-
220- - [ Vercel CLI Documentation] ( https://vercel.com/docs/cli )
221- - [ GitHub Actions Secrets] ( https://docs.github.com/en/actions/security-guides/encrypted-secrets )
222- - [ Vercel Deployment Protection] ( https://vercel.com/docs/security/deployment-protection )
223- - [ GitHub Branch Protection] ( https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches )
0 commit comments