Skip to content

Commit 9a96e87

Browse files
committed
ci: make forks build only
Restrict fork and fork-origin pull request runs to dependency installation and the Astro build, while keeping GitHub Pages and Cloudflare deployments owned by the canonical devcongress/website repository only. Move Pages write and OIDC permissions onto the Pages deployment job, gate Pages artifact upload and deployment to the canonical repository, gate Cloudflare dry-run validation and production deployment to the canonical repository, and add generic Cloudflare deployment preflight/failure messages so fork logs do not expose raw Wrangler credential diagnostics. Rename the workflow and job display names so build-only jobs appear as Build static site and production jobs appear as Deploy GitHub Pages or Deploy Cloudflare Worker instead of the misleading Build and Deploy wording. Verification: both workflow files were parsed as valid YAML, the diff passed whitespace checks, and the missing-credential Cloudflare preflight path was exercised to confirm it emits the generic Production deployment is not configured message.
1 parent e0cf96e commit 9a96e87

3 files changed

Lines changed: 35 additions & 14 deletions

File tree

.github/workflows/deploy-cloudflare-workers.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Deploy Cloudflare Worker
1+
name: Cloudflare Worker
22

33
on:
44
push:
@@ -20,6 +20,7 @@ concurrency:
2020

2121
jobs:
2222
validate-and-build:
23+
name: Build static site
2324
runs-on: ubuntu-latest
2425
steps:
2526
- name: Checkout
@@ -43,10 +44,12 @@ jobs:
4344
run: pnpm build
4445

4546
- name: Validate Worker deployment
47+
if: github.repository == 'devcongress/website' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
4648
run: pnpm wrangler deploy --dry-run
4749

4850
deploy:
49-
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
51+
name: Deploy Cloudflare Worker
52+
if: github.repository == 'devcongress/website' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
5053
needs: validate-and-build
5154
runs-on: ubuntu-latest
5255
environment:
@@ -72,10 +75,22 @@ jobs:
7275
- name: Build
7376
run: pnpm build
7477

75-
- name: Deploy static site
76-
uses: cloudflare/wrangler-action@v3
77-
with:
78-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
79-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
80-
wranglerVersion: '4.107.1'
81-
command: deploy
78+
- name: Check production deployment configuration
79+
env:
80+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
81+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
82+
run: |
83+
if [ -z "$CLOUDFLARE_API_TOKEN" ] || [ -z "$CLOUDFLARE_ACCOUNT_ID" ]; then
84+
echo "::error::Production deployment is not configured."
85+
exit 1
86+
fi
87+
88+
- name: Deploy Cloudflare Worker
89+
env:
90+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
91+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
92+
run: |
93+
if ! pnpm wrangler deploy > "$RUNNER_TEMP/wrangler-deploy.log" 2>&1; then
94+
echo "::error::Production deployment failed."
95+
exit 1
96+
fi

.github/workflows/deploy.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Deploy GitHub Pages
1+
name: GitHub Pages
22

33
on:
44
push:
@@ -13,15 +13,14 @@ on:
1313

1414
permissions:
1515
contents: read
16-
pages: write
17-
id-token: write
1816

1917
concurrency:
2018
group: github-pages
2119
cancel-in-progress: false
2220

2321
jobs:
2422
build:
23+
name: Build static site
2524
runs-on: ubuntu-latest
2625
steps:
2726
- name: Checkout
@@ -45,15 +44,20 @@ jobs:
4544
run: pnpm build
4645

4746
- name: Upload GitHub Pages artifact
48-
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
47+
if: github.repository == 'devcongress/website' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
4948
uses: actions/upload-pages-artifact@v3
5049
with:
5150
path: dist/
5251

5352
deploy:
54-
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
53+
name: Deploy GitHub Pages
54+
if: github.repository == 'devcongress/website' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
5555
needs: build
5656
runs-on: ubuntu-latest
57+
permissions:
58+
contents: read
59+
pages: write
60+
id-token: write
5761
environment:
5862
name: github-pages
5963
url: ${{ steps.deployment.outputs.page_url }}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Before the first production deployment, repository administrators must create th
5353
- `CLOUDFLARE_ACCOUNT_ID` — the Cloudflare account that owns the Worker and `devcongress.org` zone.
5454

5555
The first deployment should be validated at its Workers preview URL. Attach `devcongress.org` only after URL/content parity checks pass. GitHub Pages continues to deploy independently during the agreed soak window and remains the rollback path.
56+
57+
Forks and fork-origin pull requests run the build jobs only. GitHub Pages artifacts, Workers dry-run validation, protected environments, and production deployments run only from `devcongress/website` itself.
5658
## 👀 Want to learn more?
5759

5860
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).

0 commit comments

Comments
 (0)