Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions .github/workflows/build-and-deploy.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Build workflow - runs for both PRs and main branch pushes
# This workflow builds the website without access to secrets
# For PRs: Runs on untrusted fork code safely (using pull_request event, not pull_request_target)
# For main: Builds and uploads artifacts for deployment
# Artifacts are passed to the deploy workflow which has access to secrets

name: Build

permissions:
contents: read

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
BUILD_PATH: 'dist'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# - For PRs: PR head commit
# - For pushes: the pushed commit
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}


- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci --prefer-offline --no-audit --progress=false

- name: Build project
run: npm run build

# Upload artifact for deploy workflow
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: blog-build-${{ github.run_id }}
path: ${{ env.BUILD_PATH }}
retention-days: 1
45 changes: 45 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Deploy workflow - triggered by workflow_run after successful build
# This workflow has access to secrets but never executes untrusted code
# It only downloads and deploys pre-built artifacts from the build workflow
# Security: Fork code cannot access secrets as it only runs in build workflow
# Deploys to IPFS for all branches

name: Deploy

# Explicitly declare permissions
permissions:
contents: read
pull-requests: write
statuses: write

on:
workflow_run:
workflows: ["Build"]
types: [completed]

env:
BUILD_PATH: 'blog-build'

jobs:
deploy-ipfs:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
outputs:
cid: ${{ steps.deploy.outputs.cid }}
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: blog-build-${{ github.event.workflow_run.id }}
path: ${{ env.BUILD_PATH }}
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}

- name: Deploy to IPFS
uses: ipshipyard/ipfs-deploy-action@v1
id: deploy
with:
path-to-deploy: ${{ env.BUILD_PATH }}
storacha-key: ${{ secrets.STORACHA_KEY }}
storacha-proof: ${{ secrets.STORACHA_PROOF }}
github-token: ${{ github.token }}