Skip to content

Commit 8343144

Browse files
committed
Update GH Actions workflows to use GH Secrets for env vars
1 parent a826a88 commit 8343144

3 files changed

Lines changed: 129 additions & 0 deletions

File tree

.github/workflows/build-and-test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ jobs:
1111
name: Build and Test
1212
runs-on: ubuntu-latest
1313

14+
# Define environment variables once at the job level
15+
# These will be available to ALL steps in this job
16+
env:
17+
CONVERTKIT_API_KEY: ${{ secrets.CONVERTKIT_API_KEY }}
18+
CONVERTKIT_FORM_ID: ${{ secrets.CONVERTKIT_FORM_ID }}
19+
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
20+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
21+
PUBLIC_SENTRY_DSN: ${{ secrets.PUBLIC_SENTRY_DSN }}
22+
WEBMENTION_IO_TOKEN: ${{ secrets.WEBMENTION_IO_TOKEN }}
23+
1424
steps:
1525
- name: Checkout repository
1626
uses: actions/checkout@v4

.github/workflows/type-check.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ jobs:
1111
name: Code Quality Check
1212
runs-on: ubuntu-latest
1313

14+
# Define environment variables once at the job level
15+
# These will be available to ALL steps in this job
16+
env:
17+
CONVERTKIT_API_KEY: ${{ secrets.CONVERTKIT_API_KEY }}
18+
CONVERTKIT_FORM_ID: ${{ secrets.CONVERTKIT_FORM_ID }}
19+
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
20+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
21+
PUBLIC_SENTRY_DSN: ${{ secrets.PUBLIC_SENTRY_DSN }}
22+
WEBMENTION_IO_TOKEN: ${{ secrets.WEBMENTION_IO_TOKEN }}
23+
1424
steps:
1525
- name: Checkout repository
1626
uses: actions/checkout@v4

docs/GITHUB_SECRETS_SETUP.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# GitHub Secrets Setup Guide
2+
3+
This document explains how to configure GitHub Secrets for CI/CD workflows.
4+
5+
## Required Secrets
6+
7+
The following secrets must be configured in your GitHub repository for the CI/CD pipelines to work:
8+
9+
### Required for Build & Deployment
10+
11+
- `CONVERTKIT_API_KEY` - ConvertKit API key for newsletter integration
12+
- `CONVERTKIT_FORM_ID` - ConvertKit form ID (numeric value)
13+
- `RESEND_API_KEY` - Resend API key for email functionality
14+
15+
### Required for Vercel Deployment
16+
17+
- `VERCEL_TOKEN` - Vercel deployment token
18+
- `VERCEL_PROJECT_ID` - Your Vercel project ID
19+
- `VERCEL_ORG_ID` - Your Vercel organization ID
20+
21+
### Optional but Recommended
22+
23+
- `SENTRY_AUTH_TOKEN` - Sentry authentication token (required for source map uploads)
24+
- `PUBLIC_SENTRY_DSN` - Sentry DSN for error tracking
25+
- `WEBMENTION_IO_TOKEN` - WebMention.io API token for webmentions
26+
27+
## How to Add Secrets to GitHub
28+
29+
1. Navigate to your repository on GitHub
30+
2. Click on **Settings** tab
31+
3. In the left sidebar, click **Secrets and variables****Actions**
32+
4. Click **New repository secret**
33+
5. Add each secret:
34+
- **Name**: Exact name from the list above (case-sensitive)
35+
- **Value**: The actual secret value from your local `.env` file
36+
- Click **Add secret**
37+
38+
## Security Features
39+
40+
GitHub Actions automatically:
41+
-**Masks secret values** in all log output
42+
-**Prevents secrets from being printed** to console
43+
-**Blocks secret exposure** in pull requests from forks
44+
-**Encrypts secrets** at rest and in transit
45+
46+
### Example of Masked Output
47+
If a secret contains `abc123xyz`, GitHub will show:
48+
```
49+
***
50+
```
51+
52+
## Workflow Configuration
53+
54+
The secrets are injected as environment variables in the workflow files:
55+
56+
### build-and-test.yml
57+
Secrets are available in these steps:
58+
- TypeScript check
59+
- Unit tests
60+
- Build
61+
- E2E tests
62+
63+
### type-check.yml
64+
Secrets are available in:
65+
- TypeScript check
66+
67+
## Local Development
68+
69+
For local development, create a `.env` file in the project root:
70+
71+
```bash
72+
# Copy from .env.example or create manually
73+
CONVERTKIT_API_KEY=your_key_here
74+
CONVERTKIT_FORM_ID=123456
75+
RESEND_API_KEY=your_key_here
76+
SENTRY_AUTH_TOKEN=your_token_here
77+
PUBLIC_SENTRY_DSN=your_dsn_here
78+
WEBMENTION_IO_TOKEN=your_token_here
79+
```
80+
81+
**Important**: `.env` files are gitignored and should NEVER be committed to the repository.
82+
83+
## Troubleshooting
84+
85+
### "Context access might be invalid" warnings
86+
These YAML lint warnings appear before secrets are added to GitHub. They will disappear once you configure the secrets in your repository settings.
87+
88+
### Build fails with "environment variable is not set"
89+
1. Verify the secret is added in GitHub Settings
90+
2. Check the secret name matches exactly (case-sensitive)
91+
3. Ensure the workflow file references the secret correctly: `${{ secrets.SECRET_NAME }}`
92+
93+
### Secret not available in job
94+
- Secrets are not passed to workflows triggered by forks
95+
- Check that the secret is configured at the repository level (not environment level)
96+
- Verify the job has access to secrets (jobs inherit by default)
97+
98+
## Best Practices
99+
100+
1. **Rotate secrets regularly** - Update secrets periodically for security
101+
2. **Use different secrets** for different environments (dev/staging/prod)
102+
3. **Limit secret access** - Only add secrets that are necessary
103+
4. **Document secret requirements** - Keep this file updated
104+
5. **Test in PR** - Ensure workflows work before merging to main
105+
106+
## Reference
107+
108+
- [GitHub Actions Secrets Documentation](https://docs.github.com/en/actions/security-guides/encrypted-secrets)
109+
- [Astro Environment Variables](https://docs.astro.build/en/guides/environment-variables/)

0 commit comments

Comments
 (0)