feat: URL ๋ฑ๋ก๋ง์ผ๋ก OG ์๋ ์ถ์ถํ๋ ์ผ์ผ์ด์ค ํ์ด์ง ๊ตฌํ #93
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |