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
name: Deploy React App and Worker to Cloudflare | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- frontstage/** | ||
workflow_dispatch: | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "18.17.0" | ||
- name: Install dependencies | ||
run: npm install | ||
working-directory: ./frontstage | ||
- name: Build the project | ||
run: npm run build | ||
working-directory: ./frontstage # Corrected syntax | ||
- name: Deploy to Cloudflare Pages | ||
uses: cloudflare/wrangler-action@v3 | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
projectName: taiwan-public-art-information | ||
directory: ./.next | ||
command: pages deploy ./frontstage/.next/static --project-name=taiwan-public-art-information --commit-dirty=true | ||
quiet: false | ||
deploy_worker: | ||
runs-on: ubuntu-latest | ||
needs: build_and_deploy | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Deploy Worker to Cloudflare | ||
uses: cloudflare/wrangler-action@v3 | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
command: wrangler publish | ||
env: | ||
CF_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |