Skip to content

ci: update workflows #2

ci: update workflows

ci: update workflows #2

Workflow file for this run

name: Cloudflare Pages
env:
#CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
#CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
#CLOUDFLARE_PROJECT_NAME: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
CLOUDFLARE_DIRECTORY: dist
# tool versions
# renovate: datasource=npm depName=wrangler
WRANGLER_VERSION: 3.82.0
on:
push:
branches: ["main"]
permissions: {}
jobs:
pre-deployment:
if: ${{ vars.CLOUDFLARE_PROJECT_NAME != '' }}
outputs:
branch: ${{ steps.get.outputs.branch }}
environment: ${{ steps.get.outputs.environment }}
runs-on: ubuntu-latest
steps:
- id: get
run: |
if ${{ github.event_name == 'push' }}; then
echo "branch=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
else
exit 1
fi
deployment:
needs: ["pre-deployment"]
env:
BRANCH: ${{ needs.pre-deployment.outputs.branch }}
runs-on: ubuntu-latest
environment:
name: ${{ needs.pre-deployment.outputs.environment }}
url: ${{ steps.deploy.outputs.deployment-url }}
permissions:
contents: read
deployments: write
pull-requests: write
steps:
- id: pr-checkout
if: startsWith( needs.pre-deployment.outputs.branch, 'pull/' ) && endsWith( needs.pre-deployment.outputs.branch, '/merge' )
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: refs/${{ env.BRANCH }}
filter: tree:0
fetch-depth: 0
- if: steps.pr-checkout.conclusion == 'skipped'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ env.BRANCH }}
filter: tree:0
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
run_install: false
- name: Install Node.js
uses: buildjet/setup-node@6131e76b005f1e3f5c721e0ca2d8279eb577c3a8 # v4.0.4
with:
node-version-file: ".node-version"
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile --strict-peer-dependencies
- name: Build
run: pnpm build
- id: deploy
name: Deploy
uses: cloudflare/wrangler-action@9681c2997648301493e78cacbfb790a9f19c833f # v3.9.0
with:
wranglerVersion: ${{ env.WRANGLER_VERSION }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy ${{ env.CLOUDFLARE_DIRECTORY }} --project-name=${{ vars.CLOUDFLARE_PROJECT_NAME }} --branch=${{ env.BRANCH }}
- run: echo "$output" >> $GITHUB_STEP_SUMMARY
env:
output: ${{ steps.deploy.outputs.command-output }}