Deploy on the correct branch/path #1
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 to Cloudflare Pages | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy-to-cloudflare-pages: | |
runs-on: ubuntu-latest | |
environment: mainnet | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
lfs: "true" | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.npm | |
${{ github.workspace }}/.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- | |
- run: | | |
npx vite build | |
- name: Publish to Cloudflare Pages | |
uses: cloudflare/pages-action@v1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_TOKEN }} | |
# update | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
# update | |
projectName: ${{ secrets.CLOUDFLARE_APP_PROJECT_NAME }} | |
directory: out | |
# to enable Github Deployments | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
branch: main | |
workingDirectory: dist |