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
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Form backends (e.g. Formspree, Basin, Web3Forms) that accept POSTs.
# Set them as GitHub repository variables for the deployed site.
# Set them as GitHub repository variables for the deployed site (both deploy workflows read them).
# When unset, each form shows contact links instead.
PUBLIC_FORM_ENDPOINT= # contact + local network interest forms
PUBLIC_PRAYER_ENDPOINT= # prayer requests (private inbox, prayer team only)
PUBLIC_NEWSLETTER_ENDPOINT= # footer newsletter

# Public URL of the deployed site (canonical links, sitemap, robots.txt).
# Defaults to https://indigitousph.github.io. Set it when deploying to Cloudflare Workers.
SITE_URL=
42 changes: 42 additions & 0 deletions .github/workflows/deploy-cloudflare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Deploy to Cloudflare Workers

# Optional second host. Runs only when the repository variable CLOUDFLARE_ACCOUNT_ID is set,
# plus a CLOUDFLARE_API_TOKEN secret (template: "Edit Cloudflare Workers").
on:
push:
branches: [main]
workflow_dispatch:
# Daily rebuild at 00:05 Manila time (16:05 UTC) so ended events and announcements drop off.
schedule:
- cron: '5 16 * * *'

permissions:
contents: read

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

jobs:
deploy:
if: vars.CLOUDFLARE_ACCOUNT_ID != ''
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build
env:
SITE_URL: ${{ vars.CLOUDFLARE_SITE_URL }}
PUBLIC_FORM_ENDPOINT: ${{ vars.PUBLIC_FORM_ENDPOINT }}
PUBLIC_PRAYER_ENDPOINT: ${{ vars.PUBLIC_PRAYER_ENDPOINT }}
PUBLIC_NEWSLETTER_ENDPOINT: ${{ vars.PUBLIC_NEWSLETTER_ENDPOINT }}
- uses: cloudflare/wrangler-action@v4
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
packageManager: pnpm
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules/
.env.*
!.env.example
.DS_Store
.wrangler/
10 changes: 10 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pnpm dev # dev server → http://localhost:4321
pnpm check # astro check (types + content schemas)
pnpm build # check + production build → dist/
pnpm preview # serve dist/
pnpm preview:cf # serve dist/ in the local Cloudflare Workers runtime (wrangler dev)
pnpm deploy:cf # build + deploy to Cloudflare Workers (needs `wrangler login`)
pnpm format # prettier
```

Expand Down Expand Up @@ -196,6 +198,14 @@ The Indigitous global palette and fonts (from indigitous.org and the #HACK Brand

`.github/workflows/deploy.yml` builds on every PR and deploys to GitHub Pages on every push to `main`. It also runs daily at 00:05 Manila time so events expire on schedule.

The same `dist/` can also be served by **Cloudflare Workers** as static assets (no Worker script, no adapter). `wrangler.jsonc` points at `dist/`:

- The Worker is called `indigitous` and is connected to this repo through Cloudflare's Git integration (Workers Builds). Build command `pnpm run build`, deploy command `npx wrangler deploy`. The `name` in `wrangler.jsonc` must match the Worker's name in the dashboard.
- Workers Builds deploys on push but does not rebuild daily, so events and announcements can linger until the next push. `.github/workflows/deploy-cloudflare.yml` covers that: it deploys on every push to `main` and daily, like the Pages workflow. It stays off until you set the repository variable `CLOUDFLARE_ACCOUNT_ID` and the secret `CLOUDFLARE_API_TOKEN` (token template "Edit Cloudflare Workers").
- Set the variable `CLOUDFLARE_SITE_URL` (e.g. your custom domain) so canonical links, the sitemap and `robots.txt` point at the Workers host. The build reads it as `SITE_URL`; unset, it falls back to the GitHub Pages URL. For Workers Builds, set `SITE_URL` as a build variable in the Worker's settings.
- Old URLs get real 301s on Workers: the build writes `dist/_redirects` from `redirects` in `astro.config.mjs`. Cache and security headers live in `public/_headers`. GitHub Pages ignores both files.
- For a custom domain, add a `routes` entry in `wrangler.jsonc` (see the comment there).

## Open questions from the deck (needed to replace placeholders)

- [ ] Final tagline. "Locally rooted. Digitally sent." is in use for now.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The website of **Indigitous Philippines**, a movement of Filipino believers usin

_Locally rooted. Digitally sent._

Built with [Astro](https://astro.build) and [Tailwind CSS](https://tailwindcss.com) and deployed to GitHub Pages.
Built with [Astro](https://astro.build) and [Tailwind CSS](https://tailwindcss.com) and deployed to GitHub Pages. It can also be served from Cloudflare Workers (`pnpm deploy:cf`; see the Deploy section of AGENTS.md).

## Quick start

Expand Down
31 changes: 28 additions & 3 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// @ts-check
import { writeFile } from 'node:fs/promises';
import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
import sitemap from '@astrojs/sitemap';
import tailwindcss from '@tailwindcss/vite';

/**
* Old URLs from the first version of the site (incl. the retired /fil/ mirror).
* GitHub Pages is static, so each one becomes a small meta-refresh page.
* The build is static, so each one becomes a small meta-refresh page
* (and, on Cloudflare Workers, a real 301 via dist/_redirects; see below).
*/
const moved = {
'/communities': '/networks',
Expand Down Expand Up @@ -52,10 +54,33 @@ for (const p of filPages) {
redirects[`/fil${p ? `/${p}` : ''}`] = moved[/** @type {keyof typeof moved} */ (en)] ?? en;
}

/**
* Cloudflare Workers reads dist/_redirects and answers with a real 301 before the
* meta-refresh page is reached. GitHub Pages ignores the file.
* @returns {import('astro').AstroIntegration}
*/
function cloudflareRedirects() {
return {
name: 'cloudflare-redirects',
hooks: {
'astro:build:done': async ({ dir }) => {
const lines = Object.entries(redirects).map(([from, to]) => `${from} ${to} 301`);
await writeFile(new URL('_redirects', dir), `${lines.join('\n')}\n`);
},
},
};
}

// https://astro.build/config
export default defineConfig({
site: 'https://indigitousph.github.io',
// Canonical URLs, the sitemap and robots.txt use this. Set SITE_URL when deploying
// somewhere else (e.g. a Cloudflare Workers custom domain).
site: process.env.SITE_URL || 'https://indigitousph.github.io',
redirects,
integrations: [mdx(), sitemap({ filter: (page) => !page.includes('/storybook') })],
integrations: [
mdx(),
sitemap({ filter: (page) => !page.includes('/storybook') }),
cloudflareRedirects(),
],
vite: { plugins: [tailwindcss()] },
});
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"preview": "astro preview",
"check": "astro check",
"format": "prettier --write .",
"astro": "astro"
"astro": "astro",
"preview:cf": "wrangler dev",
"deploy:cf": "pnpm build && wrangler deploy"
},
"dependencies": {
"@astrojs/mdx": "^8.1.6",
Expand All @@ -23,7 +25,8 @@
"prettier": "^3.10.1",
"prettier-plugin-astro": "^1.1.2",
"prettier-plugin-tailwindcss": "^0.8.1",
"typescript": "^6.0.3"
"typescript": "^6.0.3",
"wrangler": "^4.166.0"
},
"packageManager": "pnpm@12.16.1",
"engines": {
Expand Down
Loading