Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/preview-comment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Deploying with &nbsp;<a href="https://workers.dev"><img alt="Cloudflare Workers" src="https://workers.cloudflare.com/logo.svg" width="16"></a> &nbsp;Cloudflare Workers

The latest updates on your project. Learn more about [integrating Git with Workers](https://developers.cloudflare.com/workers/ci-cd/builds/git-integration/).

| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
| ------------------------------------- | ------ | ------------- | -------------- | ------------- |
| ${STATUS} <br>[View logs](${RUN_URL}) | schedule | ${SHORT_SHA} | ${PREVIEW_URL} | ${NOW} |
16 changes: 7 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
name: Deploy to Cloudflare Workers
name: Deploy 🚀

on:
push:
branches:
- main
pull_request:
branches:
- main
branches: [main]
workflow_dispatch:

concurrency:
group: deploy-production
cancel-in-progress: false

jobs:
deploy:
# 포크 PR에는 secret이 전달되지 않으므로 같은 저장소의 PR만 미리보기 버전을 올린다
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -29,4 +28,3 @@ jobs:
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
packageManager: bun
command: ${{ github.event_name == 'push' && 'deploy' || 'versions upload' }}
55 changes: 55 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Preview 🔍

on:
pull_request:

concurrency:
group: preview-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
preview:
runs-on: ubuntu-latest
# 포크 PR에는 secret이 전달되지 않으므로 같은 저장소의 PR만 미리보기를 만든다
if: >
github.event.pull_request.head.repo.full_name == github.repository &&
github.actor != 'dependabot[bot]'
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v7

- uses: oven-sh/setup-bun@v2

- run: bun install --frozen-lockfile

- run: bun run build

- name: Upload preview version
id: upload
uses: cloudflare/wrangler-action@v4
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
packageManager: bun
command: versions upload --preview-alias pr-${{ github.event.pull_request.number }}

- name: Render comment
if: always()
env:
STATUS: ${{ steps.upload.outcome == 'success' && '✅ Ready' || '❌ Failed' }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PREVIEW_URL: <a href='https://pr-${{ github.event.pull_request.number }}-schedule.dalestudy.workers.dev'>Commit Preview URL</a>
run: |
SHORT_SHA="${HEAD_SHA::8}"
NOW="$(date -u '+%b %d %Y, %I:%M %p')"
export SHORT_SHA NOW
envsubst < .github/preview-comment.md > comment.md

- name: Comment
if: always()
uses: marocchino/sticky-pull-request-comment@v3
with:
header: cloudflare-workers
path: comment.md
Loading