Skip to content

Commit 3e868ca

Browse files
committed
chore(ci): add IPFS and DNSLink deployment
- add build.yml workflow to package web/ directory - add deploy.yml with IPFS cluster, DNSLink, and GitHub Pages - remove old deploy-pages.yml - DNSLink domain: check-ipfs-tech.dnslinks.ipshipyard.tech Related: ipshipyard/waterworks-community#23
1 parent 0b16bad commit 3e868ca

File tree

3 files changed

+138
-39
lines changed

3 files changed

+138
-39
lines changed

.github/workflows/build.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Build workflow - runs for both PRs and main branch pushes
2+
# This workflow packages the website without access to secrets
3+
# Static files from web/ directory are used as-is (no build step)
4+
# Artifacts are passed to the deploy workflow which has access to secrets
5+
6+
name: Build
7+
8+
permissions:
9+
contents: read
10+
11+
on:
12+
push:
13+
branches:
14+
- main
15+
pull_request:
16+
branches:
17+
- main
18+
19+
env:
20+
BUILD_PATH: 'web'
21+
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.ref }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
build:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
with:
33+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
34+
35+
# Upload artifact for deploy workflow
36+
- name: Upload build artifact
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: website-build-${{ github.run_id }}
40+
path: ${{ env.BUILD_PATH }}
41+
retention-days: 1

.github/workflows/deploy-pages.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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 and GitHub Pages for main branch only
6+
7+
name: Deploy
8+
9+
# Explicitly declare permissions
10+
permissions:
11+
actions: read
12+
contents: read
13+
pull-requests: write
14+
statuses: write
15+
16+
on:
17+
workflow_run:
18+
workflows: ["Build"]
19+
types: [completed]
20+
21+
env:
22+
BUILD_PATH: 'website-build'
23+
24+
jobs:
25+
deploy-ipfs:
26+
if: github.event.workflow_run.conclusion == 'success'
27+
runs-on: ubuntu-latest
28+
outputs:
29+
cid: ${{ steps.deploy.outputs.cid }}
30+
environment:
31+
name: 'ipfs-publish'
32+
steps:
33+
- name: Download build artifact
34+
uses: actions/download-artifact@v4
35+
with:
36+
name: website-build-${{ github.event.workflow_run.id }}
37+
path: ${{ env.BUILD_PATH }}
38+
run-id: ${{ github.event.workflow_run.id }}
39+
github-token: ${{ github.token }}
40+
41+
- name: Deploy to IPFS
42+
uses: ipshipyard/ipfs-deploy-action@v1
43+
id: deploy
44+
with:
45+
path-to-deploy: ${{ env.BUILD_PATH }}
46+
cluster-url: "/dnsaddr/ipfs-websites.collab.ipfscluster.io"
47+
cluster-user: ${{ secrets.CLUSTER_USER }}
48+
cluster-password: ${{ secrets.CLUSTER_PASSWORD }}
49+
cluster-pin-expire-in: ${{ github.event.workflow_run.head_branch != 'main' && '2160h' || '' }}
50+
github-token: ${{ github.token }}
51+
52+
dnslink-update:
53+
runs-on: ubuntu-latest
54+
needs: deploy-ipfs
55+
if: github.event.workflow_run.head_branch == 'main'
56+
environment:
57+
name: 'cf-dnslink'
58+
url: "https://check-ipfs-tech.ipns.inbrowser.link/"
59+
steps:
60+
- name: Update DNSLink
61+
uses: ipshipyard/dnslink-action@v1
62+
with:
63+
cid: ${{ needs.deploy-ipfs.outputs.cid }}
64+
dnslink_domain: 'check-ipfs-tech.dnslinks.ipshipyard.tech'
65+
cf_zone_id: ${{ secrets.CF_DNS_ZONE_ID }}
66+
cf_auth_token: ${{ secrets.CF_DNS_AUTH_TOKEN }}
67+
github_token: ${{ github.token }}
68+
set_github_status: true
69+
70+
deploy-gh-pages:
71+
if: |
72+
github.event.workflow_run.conclusion == 'success' &&
73+
github.event.workflow_run.head_branch == 'main'
74+
runs-on: ubuntu-latest
75+
permissions:
76+
pages: write
77+
id-token: write
78+
environment:
79+
name: github-pages
80+
url: ${{ steps.deployment.outputs.page_url }}
81+
steps:
82+
- name: Download build artifact
83+
uses: actions/download-artifact@v4
84+
with:
85+
name: website-build-${{ github.event.workflow_run.id }}
86+
path: website-build
87+
run-id: ${{ github.event.workflow_run.id }}
88+
github-token: ${{ github.token }}
89+
90+
- name: Upload Pages artifact
91+
uses: actions/upload-pages-artifact@v3
92+
with:
93+
path: website-build
94+
95+
- name: Deploy to GitHub Pages
96+
id: deployment
97+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)