Skip to content
Open
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
67 changes: 34 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
name: "Compile and deploy"
name: "Build Site"
on:
workflow_dispatch:
push:
branches: ['deploy']
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: 'pages'
cancel-in-progress: true
workflow_call:
inputs:
baseUrl:
required: false
default: './'
type: string
artifactName:
required: false
default: mbf-site
type: string
outputs:
artifactName:
description: 'The name of the artifact containing the built site'
value: ${{ inputs.artifactName }}


jobs:
build:
name: Build and deploy site
name: Build Site
runs-on: ubuntu-latest
env:
CC_aarch64-linux-android: /home/runner/android-ndk-r27c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android31-clang
AR_aarch64-linux-android: /home/runner/android-ndk-r27c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
BASE_URL: './'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
BASE_URL: ${{ inputs.baseUrl }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: 'true'

Expand All @@ -34,7 +36,7 @@ jobs:

- name: Agent Cache
id: agent_cache
uses: actions/cache@v4
uses: actions/cache@v5
with:
key: mbf-agent-${{ steps.agent_hash.outputs.hash }}
path: |
Expand All @@ -43,7 +45,7 @@ jobs:

- name: Rust target cache
if: steps.agent_cache.outputs.cache-hit != 'true'
uses: actions/cache@v4
uses: actions/cache@v5
with:
key: rust-target-newlibmain-${{ steps.agent_hash.outputs.hash }}
restore-keys: rust-target-newlibmain-
Expand Down Expand Up @@ -89,7 +91,7 @@ jobs:
- name: Site Hash
id: site_hash
run: |
echo "hash=$(find mbf-site -type f -exec md5sum {} \; | md5sum - | cut -d ' ' -f1)" >> $GITHUB_OUTPUT
echo "hash=$(find mbf-site ya-webadb pnpm-lock.yaml pnpm-workspace.yaml -type f -exec md5sum {} \; | md5sum - | cut -d ' ' -f1)" >> $GITHUB_OUTPUT

- name: Site Cache
id: site_cache
Expand All @@ -99,35 +101,34 @@ jobs:
path: |
mbf-site/dist

- uses: actions/setup-node@v3
- uses: actions/setup-node@v6
if: steps.site_cache.outputs.cache-hit != 'true'
with:
node-version: 20.x

- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v3
if: steps.site_cache.outputs.cache-hit != 'true'
with:
version: 9.5.0
version: latest

- name: pnpm install
if: steps.site_cache.outputs.cache-hit != 'true'
run: pnpm install

- name: pnpm build
if: steps.site_cache.outputs.cache-hit != 'true'
run: pnpm recursive run build

- name: pnpm install
if: steps.site_cache.outputs.cache-hit != 'true'
run: cd mbf-site && pnpm install

- name: pnpm build
if: steps.site_cache.outputs.cache-hit != 'true'
run: cd mbf-site && pnpm build

- name: Setup Pages
uses: actions/configure-pages@v4


- name: Upload artifact
uses: actions/upload-pages-artifact@v3
uses: actions/upload-artifact@v4
with:
path: './mbf-site/dist'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
name: ${{ inputs.artifactName }}
path: './mbf-site/dist/*'
96 changes: 96 additions & 0 deletions .github/workflows/deploy-cloudflare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Deploy to Cloudflare Pages

on:
workflow_dispatch:
push:
branches: ['*']

jobs:
check-secrets:
name: Check for Cloudflare secrets
runs-on: ubuntu-latest
outputs:
hasSecrets: ${{ steps.check.outputs.hasSecrets }}
steps:
- name: Check for secrets
id: check
run: |
if [[ -n "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}" && -n "${{ secrets.CLOUDFLARE_API_KEY }}" ]]; then
echo "hasSecrets=true" >> $GITHUB_OUTPUT
else
echo "hasSecrets=false" >> $GITHUB_OUTPUT
fi
build:
needs: check-secrets
if: ${{ needs.check-secrets.outputs.hasSecrets == 'true' }}
uses: ./.github/workflows/build.yml
with:
baseUrl: './'
artifactName: mbf-site

cf-pages:
env:
COMPATIBILITY_DATE: 2026-04-06

name: Deploy to Cloudflare Pages
if: ${{ needs.check-secrets.outputs.hasSecrets == 'true' }}
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ steps.build.outputs.artifactName }}
path: .

- name: Get default branch
id: repo
run: |
DEFAULT_BRANCH=$(curl -s \
-H "Authorization: Bearer ${{ github.token }}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/${{ github.repository }} \
| jq -r .default_branch)
echo "default_branch=$DEFAULT_BRANCH" >> $GITHUB_OUTPUT

if [[ -n "${{ secrets.CLOUDFLARE_DEPLOY_BRANCH }}" ]]; then
echo "Deploy branch set to ${{ secrets.CLOUDFLARE_DEPLOY_BRANCH }}"
DEPLOY_BRANCH=${{ secrets.CLOUDFLARE_DEPLOY_BRANCH }}
else
echo "Deploy branch not set, using default branch $DEFAULT_BRANCH"
DEPLOY_BRANCH=$DEFAULT_BRANCH
fi
SAFE_BRANCH=$(echo "${{ github.ref_name }}" | tr '/' '-')
echo "short_sha=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
echo "safe_branch=$SAFE_BRANCH" >> $GITHUB_OUTPUT
echo "deploy_branch=$DEPLOY_BRANCH" >> $GITHUB_OUTPUT

- name: Deploy to Cloudflare (Version)
id: branch-deploy
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: '*'
apiToken: ${{ secrets.CLOUDFLARE_API_KEY }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: versions upload --assets ./mbf-site --preview-alias "${{ steps.repo.outputs.safe_branch }}" "--name=modsbeforefriday" --compatibility-date ${{ env.COMPATIBILITY_DATE }}

- name: Update job summary
env:
cmd_output: ${{ steps.branch-deploy.outputs.command-output }}
run: |
echo "$cmd_output" | grep "Version Preview " >> $GITHUB_STEP_SUMMARY

- name: Deploy to Cloudflare
id: deploy
if: github.ref_name == steps.repo.outputs.deploy_branch
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: '*'
apiToken: ${{ secrets.CLOUDFLARE_API_KEY }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: deploy --assets ./mbf-site --name=modsbeforefriday --compatibility-date ${{ env.COMPATIBILITY_DATE }}

- name: Update job summary
if: github.ref_name == steps.repo.outputs.deploy_branch
run: |
echo "Deployment URL: ${{ steps.deploy.outputs.deployment-url }}" >> $GITHUB_STEP_SUMMARY
42 changes: 42 additions & 0 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "Compile and deploy"
on:
workflow_dispatch:
push:
branches: ['deploy']

concurrency:
group: 'pages'
cancel-in-progress: true

jobs:
build:
uses: ./.github/workflows/build.yml
with:
baseUrl: './'
artifactName: mbf-site

gh-pages:
name: Deploy to GitHub Pages
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: read
pages: write
id-token: write
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
path: .

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './mbf-site/'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4