.github/workflows/publish_website.yml #157
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/[email protected] | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: ${{ secrets.CLOUDFLARE_PAGES_PROJECT_NAME }} | |
directory: dist/client | |
# Optional: Enable this if you want to have GitHub Deployments triggered | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
# Optional: Switch what branch you are publishing to. | |
# By default, this will be the branch which triggered this workflow | |
branch: main | |
# Optional: Change the working directory | |
workingDirectory: website | |
# Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta` | |
wranglerVersion: '3' | |