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/Storacha for all branches and GitHub Pages for main branch only
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 : ' cid-utils-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 : cid-utils-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/Storacha
39+ uses : ipfs/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 }}
46+
47+ deploy-gh-pages :
48+ if : |
49+ github.event.workflow_run.conclusion == 'success' &&
50+ github.event.workflow_run.head_branch == 'main'
51+ runs-on : ubuntu-latest
52+ permissions :
53+ pages : write
54+ id-token : write
55+ environment :
56+ name : github-pages
57+ url : ${{ steps.deployment.outputs.page_url }}
58+ steps :
59+ - name : Download build artifact
60+ uses : actions/download-artifact@v4
61+ with :
62+ name : cid-utils-build-${{ github.event.workflow_run.id }}
63+ path : cid-utils-build
64+ run-id : ${{ github.event.workflow_run.id }}
65+ github-token : ${{ github.token }}
66+
67+ - name : Upload Pages artifact
68+ uses : actions/upload-pages-artifact@v3
69+ with :
70+ path : cid-utils-build
71+
72+ - name : Deploy to GitHub Pages
73+ id : deployment
74+ uses : actions/deploy-pages@v4
0 commit comments