|
| 1 | +name: Deploy www (manual SHA) |
| 2 | + |
| 3 | +# Maintainer escape hatch: deploy any commit to a stable www URL without |
| 4 | +# pushing that commit to the target branch. Requires write access to run. |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + sha: |
| 9 | + description: Full commit SHA to build and deploy |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + target: |
| 13 | + description: Stable URL to update |
| 14 | + required: true |
| 15 | + type: choice |
| 16 | + options: |
| 17 | + - arkenv-dev.vercel.app |
| 18 | + - arkenv-v1.vercel.app |
| 19 | + - arkenv.js.org |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: deploy-www-manual-${{ inputs.target }} |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | +jobs: |
| 26 | + Deploy-Manual: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + env: |
| 29 | + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} |
| 30 | + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} |
| 31 | + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} |
| 32 | + TURBO_TEAM: ${{ vars.TURBO_TEAM }} |
| 33 | + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} |
| 34 | + TARGET: ${{ inputs.target }} |
| 35 | + DEPLOY_SHA: ${{ inputs.sha }} |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v6 |
| 38 | + with: |
| 39 | + ref: ${{ inputs.sha }} |
| 40 | + fetch-depth: 0 |
| 41 | + - name: Resolve git metadata for the deployed commit |
| 42 | + id: meta |
| 43 | + run: | |
| 44 | + set -euo pipefail |
| 45 | + case "$TARGET" in |
| 46 | + arkenv-dev.vercel.app) echo "git_ref=dev" >> "$GITHUB_OUTPUT" ;; |
| 47 | + arkenv-v1.vercel.app) echo "git_ref=v1" >> "$GITHUB_OUTPUT" ;; |
| 48 | + arkenv.js.org) echo "git_ref=main" >> "$GITHUB_OUTPUT" ;; |
| 49 | + *) |
| 50 | + echo "Unknown target: $TARGET" >&2 |
| 51 | + exit 1 |
| 52 | + ;; |
| 53 | + esac |
| 54 | + echo "short_msg=$(git log -1 --format=%s "$DEPLOY_SHA" | head -n1)" >> "$GITHUB_OUTPUT" |
| 55 | + echo "author_name=$(git log -1 --format=%an "$DEPLOY_SHA")" >> "$GITHUB_OUTPUT" |
| 56 | + - uses: pnpm/action-setup@v6 |
| 57 | + - uses: actions/setup-node@v6 |
| 58 | + with: |
| 59 | + node-version: lts/* |
| 60 | + cache: pnpm |
| 61 | + - name: Install dependencies |
| 62 | + run: pnpm install |
| 63 | + - name: Install Vercel CLI |
| 64 | + # Pin the CLI to avoid upstream breakage from newly published majors. |
| 65 | + run: npm install --global vercel@54.7.1 |
| 66 | + - name: Pull Vercel Environment Information |
| 67 | + run: | |
| 68 | + if [ "$TARGET" = "arkenv.js.org" ]; then |
| 69 | + node scripts/vercel-wrapper.cjs pull --yes --environment=production --token="$VERCEL_TOKEN" |
| 70 | + else |
| 71 | + node scripts/vercel-wrapper.cjs pull --yes --environment=preview --token="$VERCEL_TOKEN" |
| 72 | + fi |
| 73 | + - name: Build Project Artifacts |
| 74 | + run: | |
| 75 | + if [ "$TARGET" = "arkenv.js.org" ]; then |
| 76 | + node scripts/vercel-wrapper.cjs build --prod --token="$VERCEL_TOKEN" |
| 77 | + else |
| 78 | + node scripts/vercel-wrapper.cjs build --token="$VERCEL_TOKEN" |
| 79 | + fi |
| 80 | + - name: Deploy and attach to stable URL |
| 81 | + env: |
| 82 | + GIT_ORG: ${{ github.repository_owner }} |
| 83 | + GIT_REPO: ${{ github.event.repository.name }} |
| 84 | + GIT_REF: ${{ steps.meta.outputs.git_ref }} |
| 85 | + GIT_SHA: ${{ inputs.sha }} |
| 86 | + GIT_COMMIT_MESSAGE: ${{ steps.meta.outputs.short_msg }} |
| 87 | + GIT_COMMIT_AUTHOR_NAME: ${{ steps.meta.outputs.author_name }} |
| 88 | + GIT_COMMIT_AUTHOR_LOGIN: ${{ github.actor }} |
| 89 | + run: | |
| 90 | + set -o pipefail |
| 91 | + META_ARGS=( |
| 92 | + -m githubDeployment=1 |
| 93 | + -m githubOrg="$GIT_ORG" |
| 94 | + -m githubRepo="$GIT_REPO" |
| 95 | + -m githubCommitOrg="$GIT_ORG" |
| 96 | + -m githubCommitRepo="$GIT_REPO" |
| 97 | + -m githubCommitRef="$GIT_REF" |
| 98 | + -m githubCommitSha="$GIT_SHA" |
| 99 | + -m githubCommitMessage="$GIT_COMMIT_MESSAGE" |
| 100 | + -m githubCommitAuthorName="$GIT_COMMIT_AUTHOR_NAME" |
| 101 | + -m githubCommitAuthorLogin="$GIT_COMMIT_AUTHOR_LOGIN" |
| 102 | + ) |
| 103 | + if [ "$TARGET" = "arkenv.js.org" ]; then |
| 104 | + node scripts/vercel-wrapper.cjs deploy --prebuilt --prod --archive=tgz --token="$VERCEL_TOKEN" "${META_ARGS[@]}" |
| 105 | + echo "Deployed $GIT_SHA to production (arkenv.js.org)." |
| 106 | + else |
| 107 | + DEPLOYMENT_URL=$(node scripts/vercel-wrapper.cjs deploy --prebuilt --archive=tgz --token="$VERCEL_TOKEN" "${META_ARGS[@]}" | tail -n 1) |
| 108 | + echo "Deployment URL: $DEPLOYMENT_URL" |
| 109 | + echo "Aliasing $DEPLOYMENT_URL -> $TARGET" |
| 110 | + node scripts/vercel-wrapper.cjs alias set "$DEPLOYMENT_URL" "$TARGET" --token="$VERCEL_TOKEN" |
| 111 | + fi |
0 commit comments