Skip to content

Commit

Permalink
Deploy to Cloudflare Pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Iapetus-11 committed Aug 25, 2024
1 parent 01e1f38 commit da78ba7
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
on:
workflow_call:
inputs:
environment:
required: true
type: string
outputs:
artifact-name:
value: ${{ jobs.build.outputs.artifact-name }}
secrets:
NPM_FONTAWESOME_TOKEN:
required: true

jobs:
build:
name: Build for ${{ inputs.environment }}
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}

outputs:
artifact-name: build-${{ inputs.environment }}-${{ github.run_id }}-${{ github.run_number }}

steps:
- name: Check out Git repository
uses: actions/checkout@v4

- name: Set up Node 21
uses: actions/setup-node@v4
with:
node-version: 21
cache: npm

- name: Install NPM dependencies
# Skip post-install scripts for now to prevent token theft
run: |
npm config set '//npm.fontawesome.com/:_authToken' '${NPM_FONTAWESOME_TOKEN}'
npm ci --ignore-scripts
npm config delete '//npm.fontawesome.com/:_authToken'
env:
NPM_FONTAWESOME_TOKEN: ${{ secrets.NPM_FONTAWESOME_TOKEN }}

- name: Run post-install scripts
run: npm rebuild

- name: Build project
run: npm run build

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ inputs.environment }}-${{ github.run_id }}-${{ github.run_number }}
path: dist
retention-days: 1
42 changes: 42 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Deploy to Cloudflare Pages

on:
push:
branches:
- main

concurrency:
group: deploy
cancel-in-progress: true

jobs:
build:
uses: ./.github/workflows/build.yml
with:
environment: Production
secrets: inherit

deploy:
name: Deploy
runs-on: ubuntu-latest
environment: Production
needs: build

steps:
- name: Check out Git repository
uses: actions/checkout@v4

- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.artifact-name }}
path: dist

- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
projectName: taco-tapper
branch: main
directory: dist

0 comments on commit da78ba7

Please sign in to comment.