diff --git a/.github/preview-comment.md b/.github/preview-comment.md
new file mode 100644
index 0000000..434f30d
--- /dev/null
+++ b/.github/preview-comment.md
@@ -0,0 +1,7 @@
+## Deploying with
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}
[View logs](${RUN_URL}) | schedule | ${SHORT_SHA} | ${PREVIEW_URL} | ${NOW} |
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index b21871e..80d81de 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -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
@@ -29,4 +28,3 @@ jobs:
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
packageManager: bun
- command: ${{ github.event_name == 'push' && 'deploy' || 'versions upload' }}
diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml
new file mode 100644
index 0000000..c89325a
--- /dev/null
+++ b/.github/workflows/preview.yml
@@ -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: Commit Preview URL
+ 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