Skip to content

Publish Frontend

Publish Frontend #10

name: Publish Frontend
on:
workflow_dispatch:
inputs:
project_name:
description: The project name to publish the pages to
default: frontend
required: false
type: string
workflow_call:
inputs:
project_name:
description: The project name to publish the pages to
required: true
type: string
secrets:
CLOUDFLARE_PAGES_API_TOKEN:
required: true
CLOUDFLARE_ACCOUNT_ID:
required: true
jobs:
publish:
name: Publish to Cloudflare Pages
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Cache node_modules
uses: actions/cache@v4
id: node_cache
with:
path: node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: npm install
if: steps.node_cache.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
- name: Prisma Generate
run: npx nx run db:generate
- name: Build Frontend
run: npx nx run frontend:build:${{ contains( inputs.project_name, 'staging' ) && 'staging' || 'production' }}
- name: Publish to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_PAGES_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy dist/apps/frontend --project-name=${{ inputs.project_name }} --commit-dirty=true