Skip to content

.github/workflows/publish_website.yml #492

.github/workflows/publish_website.yml

.github/workflows/publish_website.yml #492

on:
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Every day at midnight
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Publish to Cloudflare Pages
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python (This is needed for the DB Connection check)
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Sanity check for DB Connection
run: python scripts/check_db_connection.py
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
cache: 'yarn'
cache-dependency-path: website/yarn.lock
- name: Migrate production database with prisma
run: bash scripts/migrate.sh
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
- name: Install Node.js dependencies
run: yarn install --frozen-lockfile
working-directory: website
- name: Generate Prisma Client
# Working directory is "./" on purpose!
run: npx prisma generate
- name: Build
run: yarn build
working-directory: website
env:
NODE_ENV: production
DATABASE_URL: ${{ secrets.DATABASE_URL }}
PUBLIC_SERVER_URL: ${{ secrets.PUBLIC_SERVER_URL }}
PUBLIC_TURNSTILE_SITEKEY: ${{ secrets.PUBLIC_TURNSTILE_SITEKEY }}
PUBLIC_GTAG: ${{ secrets.PUBLIC_GTAG }}
- name: Publish to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy dist/client --project-name=${{ secrets.CLOUDFLARE_PAGES_PROJECT_NAME }} --branch=main
workingDirectory: website