Skip to content

Commit

Permalink
feat: add preview environment and display its url
Browse files Browse the repository at this point in the history
  • Loading branch information
taga3s committed Nov 4, 2024
1 parent 96c776f commit 374d403
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ name: deploy

on:
push:
branches:
- main

permissions:
contents: read
deployments: write
statuses: write

jobs:
deploy:
Expand All @@ -33,8 +32,24 @@ jobs:
run: pnpm build

- name: Publish to Cloudflare Pages
id: cloudflare-pages-deploy
uses: cloudflare/wrangler-action@v3
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: pages deploy ./dist --project-name=taga3s-dev-website

- name: Add publish URL as commit status
uses: actions/github-script@v6
with:
script: |
const sha = context.payload.pull_request?.head.sha ?? context.sha;
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
context: 'Cloudflare Pages',
description: 'Cloudflare Pages deployment',
state: 'success',
sha,
target_url: "${{ steps.cloudflare-pages-deploy.outputs.deployment-url }}",
});

0 comments on commit 374d403

Please sign in to comment.