Skip to content

feat: URL ๋“ฑ๋ก๋งŒ์œผ๋กœ OG ์ž๋™ ์ถ”์ถœํ•˜๋Š” ์‡ผ์ผ€์ด์Šค ํŽ˜์ด์ง€ ๊ตฌํ˜„ #93

feat: URL ๋“ฑ๋ก๋งŒ์œผ๋กœ OG ์ž๋™ ์ถ”์ถœํ•˜๋Š” ์‡ผ์ผ€์ด์Šค ํŽ˜์ด์ง€ ๊ตฌํ˜„

feat: URL ๋“ฑ๋ก๋งŒ์œผ๋กœ OG ์ž๋™ ์ถ”์ถœํ•˜๋Š” ์‡ผ์ผ€์ด์Šค ํŽ˜์ด์ง€ ๊ตฌํ˜„ #93

Workflow file for this run

name: Preview ๐Ÿ”
on:
pull_request:
concurrency:
group: preview-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
preview:
runs-on: ubuntu-latest
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
# ๋Œ“๊ธ€์— ํ‘œ์‹œํ•  ์งง์€ ์ปค๋ฐ‹ ํ•ด์‹œ์™€ UTC ์‹œ๊ฐ ๊ณ„์‚ฐ
- name: Prepare commit metadata
id: commit
run: |
echo "short_sha=$(echo '${{ github.event.pull_request.head.sha }}' | cut -c1-8)" >> "$GITHUB_OUTPUT"
echo "now=$(date -u '+%b %d %Y, %I:%M %p')" >> "$GITHUB_OUTPUT"
alias="pr-${{ github.event.pull_request.number }}"
echo "alias=$alias" >> "$GITHUB_OUTPUT"
echo "preview_url=https://$alias-daleui.dalestudy.workers.dev" >> "$GITHUB_OUTPUT"
- uses: oven-sh/setup-bun@v2
- run: bun install --frozen-lockfile
# OG ์ด๋ฏธ์ง€๋ฅผ CI ์‹คํ–‰ ๊ฐ„์— ๋ณด์กดํ•ด cache-cold๋กœ ๋งค๋ฒˆ ์ „๋ถ€ ์žฌ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ์„ ๋ฐฉ์ง€.
- name: Cache OG images
uses: actions/cache@v6
with:
path: public/og
key: og-${{ hashFiles('src/og/**', 'scripts/generate-og.mts', 'public/newLogoWithText.svg', 'public/og-background.png') }}
restore-keys: |
og-
- run: bun run build
env:
VITE_SITE_URL: ${{ steps.commit.outputs.preview_url }}
# ๋ฐฐํฌ ์‹œ์ž‘ ์‹œ์ ์— "In progress" ์ƒํƒœ๋กœ ๋Œ“๊ธ€์„ ๋จผ์ € ๋‚จ๊น€(๊ฐฑ์‹ )
- name: Render in-progress comment
env:
STATUS: ๐Ÿ”ต In progress
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SHORT_SHA: ${{ steps.commit.outputs.short_sha }}
PREVIEW_URL: "-"
NOW: ${{ steps.commit.outputs.now }}
run: envsubst < .github/preview-comment.md > comment.md
- name: Comment build in progress
uses: marocchino/sticky-pull-request-comment@v3
with:
header: cloudflare-workers
path: comment.md
- name: Upload preview version to Cloudflare Workers
id: deploy
uses: cloudflare/wrangler-action@v4
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: "94480614a6df7731f1e4491bdac5c440"
packageManager: bun
# alias๋ฅผ PR ๋ฒˆํ˜ธ๋กœ ๊ณ ์ •ํ•ด ๋นŒ๋“œ์— ์ฃผ์ž…ํ•œ VITE_SITE_URL๊ณผ ๋™์ผํ•œ ๋„๋ฉ”์ธ์„ ๋ณด์žฅ.
command: versions upload --preview-alias ${{ steps.commit.outputs.alias }}
# ๋ฐฐํฌ ์™„๋ฃŒ ํ›„ ๋™์ผ ๋Œ“๊ธ€์„ ์„ฑ๊ณต ์ƒํƒœ๋กœ ๊ฐฑ์‹ (sticky)ํ•˜์—ฌ ๋Œ“๊ธ€์ด ์Œ“์ด์ง€ ์•Š๋„๋ก ํ•จ
- name: Render ready comment
env:
STATUS: โœ… Ready
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SHORT_SHA: ${{ steps.commit.outputs.short_sha }}
PREVIEW_URL: <a href='${{ steps.commit.outputs.preview_url }}'>Commit Preview URL</a>
NOW: ${{ steps.commit.outputs.now }}
run: envsubst < .github/preview-comment.md > comment.md
- name: Comment preview URL on PR
uses: marocchino/sticky-pull-request-comment@v3
with:
header: cloudflare-workers
path: comment.md