Vero 🐙
04/11/2023, 12:02 PMVero 🐙
04/11/2023, 12:02 PMname: Build & CF Pages Deploy
on:
push:
branches:
- deploy/staging
- deploy/production
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/deploy/production' && 'production' || 'preview' }}
steps:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x.x
- name: Checkout
uses: actions/checkout@v3
- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ubuntu-latest-node-v16.x.x-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/package-lock.json')) }}
- name: Extract Branch Name
uses: nelonoel/branch-name@v1.0.1
- name: Install Dependencies
run: npm install
- name: Environment Variables
run: echo "${{ vars.ENV_FILE }}" > .env
- name: Create Bundle
run: npm run build
env:
NITRO_PRESET: cloudflare-pages
- name: Create CF Pages Project
uses: cloudflare/wrangler-action@2.0.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
command: pages project create ${{ github.event.repository.name }} --production-branch=deploy/production
continue-on-error: true
- name: Publish to CF Pages
uses: cloudflare/wrangler-action@2.0.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
command: pages publish .output --project-name=${{ github.event.repository.name }} --branch=${BRANCH_NAME}
Vero 🐙
04/11/2023, 12:10 PM