File tree Expand file tree Collapse file tree 3 files changed +102
-44
lines changed
Expand file tree Collapse file tree 3 files changed +102
-44
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ # Build workflow - runs for both PRs and main branch pushes
2+ # This workflow builds the website without access to secrets
3+ # For PRs: Runs on untrusted fork code safely (using pull_request event, not pull_request_target)
4+ # For main: Builds and uploads artifacts for deployment
5+ # Artifacts are passed to the deploy workflow which has access to secrets
6+
7+ name : Build
8+
9+ permissions :
10+ contents : read
11+
12+ on :
13+ push :
14+ branches :
15+ - main
16+ pull_request :
17+ branches :
18+ - main
19+
20+ env :
21+ BUILD_PATH : ' dist'
22+
23+ concurrency :
24+ group : ${{ github.workflow }}-${{ github.ref }}
25+ cancel-in-progress : true
26+
27+ jobs :
28+ build :
29+ runs-on : ubuntu-latest
30+ steps :
31+ - name : Checkout code
32+ uses : actions/checkout@v4
33+ with :
34+ # - For PRs: PR head commit
35+ # - For pushes: the pushed commit
36+ ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
37+
38+
39+ - name : Setup Node.js
40+ uses : actions/setup-node@v4
41+ with :
42+ node-version : ' 20'
43+ cache : ' npm'
44+
45+ - name : Install dependencies
46+ run : npm ci --prefer-offline --no-audit --progress=false
47+
48+ - name : Build project
49+ run : npm run build
50+
51+ # Upload artifact for deploy workflow
52+ - name : Upload build artifact
53+ uses : actions/upload-artifact@v4
54+ with :
55+ name : blog-build-${{ github.run_id }}
56+ path : ${{ env.BUILD_PATH }}
57+ retention-days : 1
Original file line number Diff line number Diff line change 1+ # Deploy workflow - triggered by workflow_run after successful build
2+ # This workflow has access to secrets but never executes untrusted code
3+ # It only downloads and deploys pre-built artifacts from the build workflow
4+ # Security: Fork code cannot access secrets as it only runs in build workflow
5+ # Deploys to IPFS for all branches
6+
7+ name : Deploy
8+
9+ # Explicitly declare permissions
10+ permissions :
11+ contents : read
12+ pull-requests : write
13+ statuses : write
14+
15+ on :
16+ workflow_run :
17+ workflows : ["Build"]
18+ types : [completed]
19+
20+ env :
21+ BUILD_PATH : ' blog-build'
22+
23+ jobs :
24+ deploy-ipfs :
25+ if : github.event.workflow_run.conclusion == 'success'
26+ runs-on : ubuntu-latest
27+ outputs :
28+ cid : ${{ steps.deploy.outputs.cid }}
29+ steps :
30+ - name : Download build artifact
31+ uses : actions/download-artifact@v4
32+ with :
33+ name : blog-build-${{ github.event.workflow_run.id }}
34+ path : ${{ env.BUILD_PATH }}
35+ run-id : ${{ github.event.workflow_run.id }}
36+ github-token : ${{ github.token }}
37+
38+ - name : Deploy to IPFS
39+ uses : ipshipyard/ipfs-deploy-action@v1
40+ id : deploy
41+ with :
42+ path-to-deploy : ${{ env.BUILD_PATH }}
43+ storacha-key : ${{ secrets.STORACHA_KEY }}
44+ storacha-proof : ${{ secrets.STORACHA_PROOF }}
45+ github-token : ${{ github.token }}
You can’t perform that action at this time.
0 commit comments