From b780595c58ae14be49153887e3d162d3d9e0aa0b Mon Sep 17 00:00:00 2001 From: Goder-0 Date: Wed, 27 May 2026 21:26:59 +0900 Subject: [PATCH 1/2] Chore: add Vercel release workflows (#514) - Add a preview deployment workflow for pull requests and main updates. - Add a tag-based production release workflow. - Generate GitHub Releases from the production workflow. - Closes #514. --- .github/workflows/cd.yml | 101 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 66 ++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 .github/workflows/cd.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 00000000..24690532 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,101 @@ +name: Linkiving frontend CD + +on: + workflow_dispatch: + push: + branches: + - main + pull_request: + branches: + - main + types: + - opened + - synchronize + - reopened + +permissions: + contents: read + pull-requests: write + +concurrency: + group: frontend-cd-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +jobs: + deploy-preview: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10.19.0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22.x' + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Install Vercel CLI + run: npm install --global vercel@latest + + - name: Pull Vercel preview environment + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build Vercel artifacts + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + + - name: Deploy preview to Vercel + id: deploy + shell: bash + run: | + deployment_url="$(vercel deploy --prebuilt --archive=tgz --token=${{ secrets.VERCEL_TOKEN }})" + echo "deployment_url=${deployment_url}" >> "$GITHUB_OUTPUT" + echo "Preview deployment: ${deployment_url}" >> "$GITHUB_STEP_SUMMARY" + + - name: Add PR preview comment + if: github.event_name == 'pull_request' + uses: actions/github-script@v7 + env: + DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment_url }} + with: + script: | + const marker = ''; + const body = `${marker}\nPreview deployment is ready.\n\n- URL: ${process.env.DEPLOYMENT_URL}\n- Commit: ${context.sha}`; + const { owner, repo } = context.repo; + const issue_number = context.issue.number; + const comments = await github.paginate(github.rest.issues.listComments, { + owner, + repo, + issue_number, + per_page: 100, + }); + const existing = comments.find((comment) => comment.user?.type === 'Bot' && comment.body?.includes(marker)); + + if (existing) { + await github.rest.issues.updateComment({ + owner, + repo, + comment_id: existing.id, + body, + }); + return; + } + + await github.rest.issues.createComment({ + owner, + repo, + issue_number, + body, + }); diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..758fe01f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: Vercel Production Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +concurrency: + group: vercel-release-${{ github.ref }} + cancel-in-progress: false + +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +jobs: + deploy-production: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10.19.0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22.x' + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Install Vercel CLI + run: npm install --global vercel@latest + + - name: Pull Vercel production environment + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build production artifacts + run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + + - name: Deploy production to Vercel + id: deploy + shell: bash + run: | + deployment_url="$(vercel deploy --prebuilt --archive=tgz --prod --token=${{ secrets.VERCEL_TOKEN }})" + echo "deployment_url=${deployment_url}" >> "$GITHUB_OUTPUT" + { + echo "Production release deployed." + echo + echo "- Tag: ${{ github.ref_name }}" + echo "- URL: ${deployment_url}" + } >> "$GITHUB_STEP_SUMMARY" + + - name: Create GitHub release + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true From 1fb28ee216ce16d3ef80a8bba732cdbd359a3cd7 Mon Sep 17 00:00:00 2001 From: Goder-0 Date: Sun, 21 Jun 2026 20:51:49 +0900 Subject: [PATCH 2/2] Refine Vercel release workflow Remove the preview deployment workflow so Vercel Git integration remains the preview source of truth. Keep only the tag-driven workflow and harden its checkout and tag summary handling. --- .github/workflows/cd.yml | 101 ---------------------------------- .github/workflows/release.yml | 8 ++- 2 files changed, 6 insertions(+), 103 deletions(-) delete mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index 24690532..00000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,101 +0,0 @@ -name: Linkiving frontend CD - -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - branches: - - main - types: - - opened - - synchronize - - reopened - -permissions: - contents: read - pull-requests: write - -concurrency: - group: frontend-cd-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - -jobs: - deploy-preview: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 10.19.0 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '22.x' - cache: 'pnpm' - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Install Vercel CLI - run: npm install --global vercel@latest - - - name: Pull Vercel preview environment - run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} - - - name: Build Vercel artifacts - run: vercel build --token=${{ secrets.VERCEL_TOKEN }} - - - name: Deploy preview to Vercel - id: deploy - shell: bash - run: | - deployment_url="$(vercel deploy --prebuilt --archive=tgz --token=${{ secrets.VERCEL_TOKEN }})" - echo "deployment_url=${deployment_url}" >> "$GITHUB_OUTPUT" - echo "Preview deployment: ${deployment_url}" >> "$GITHUB_STEP_SUMMARY" - - - name: Add PR preview comment - if: github.event_name == 'pull_request' - uses: actions/github-script@v7 - env: - DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment_url }} - with: - script: | - const marker = ''; - const body = `${marker}\nPreview deployment is ready.\n\n- URL: ${process.env.DEPLOYMENT_URL}\n- Commit: ${context.sha}`; - const { owner, repo } = context.repo; - const issue_number = context.issue.number; - const comments = await github.paginate(github.rest.issues.listComments, { - owner, - repo, - issue_number, - per_page: 100, - }); - const existing = comments.find((comment) => comment.user?.type === 'Bot' && comment.body?.includes(marker)); - - if (existing) { - await github.rest.issues.updateComment({ - owner, - repo, - comment_id: existing.id, - body, - }); - return; - } - - await github.rest.issues.createComment({ - owner, - repo, - issue_number, - body, - }); diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 758fe01f..0925cbcb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Vercel Production Release +name: Linkiving frontend release on: push: @@ -19,10 +19,14 @@ env: jobs: deploy-production: runs-on: ubuntu-latest + env: + TAG_NAME: ${{ github.ref_name }} steps: - name: Checkout repository uses: actions/checkout@v4 + with: + persist-credentials: false - name: Setup pnpm uses: pnpm/action-setup@v4 @@ -56,7 +60,7 @@ jobs: { echo "Production release deployed." echo - echo "- Tag: ${{ github.ref_name }}" + echo "- Tag: ${TAG_NAME}" echo "- URL: ${deployment_url}" } >> "$GITHUB_STEP_SUMMARY"