name: Vercel PR Deploy (Preview) env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} ALIASES: ${{ vars.ALIASES }} on: issue_comment: types: [created] pull_request_target: jobs: deploy: runs-on: ubuntu-latest if: >- ( ( github.event_name == 'issue_comment' && contains(github.event.comment.body, '/deploy') && github.event.issue.pull_request != null ) || ( github.event_name == 'pull_request_target' && contains(fromJson(vars.AUTO_DEPLOY_PRS), github.event.pull_request.number) ) ) permissions: pull-requests: write steps: - name: Checkout Base To Temp uses: actions/checkout@v2 with: path: temp-base-repo - name: Get deployment alias run: node temp-base-repo/scripts/githubActions.mjs getAlias id: alias env: ALIASES: ${{ env.ALIASES }} PULL_URL: ${{ github.event.issue.pull_request.url || github.event.pull_request.url }} - name: Checkout PR (comment) uses: actions/checkout@v2 if: github.event_name == 'issue_comment' with: ref: refs/pull/${{ github.event.issue.number }}/head - name: Checkout PR (pull_request) uses: actions/checkout@v2 if: github.event_name == 'pull_request_target' with: ref: refs/pull/${{ github.event.pull_request.number }}/head - name: Install pnpm uses: pnpm/action-setup@v4 - uses: actions/setup-node@v4 with: node-version: 22 cache: "pnpm" - name: Update deployAlwaysUpdate packages run: | if [ -f package.json ]; then PACKAGES=$(node -e "const pkg = require('./package.json'); if (pkg.deployAlwaysUpdate) console.log(pkg.deployAlwaysUpdate.join(' '))") if [ ! -z "$PACKAGES" ]; then echo "Updating packages: $PACKAGES" pnpm up -L $PACKAGES else echo "No deployAlwaysUpdate packages found in package.json" fi else echo "package.json not found" fi - name: Install Global Dependencies run: pnpm add -g vercel - name: Pull Vercel Environment Information run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} - name: Write Release Info run: | echo "{\"latestTag\": \"$(git rev-parse --short ${{ github.event.pull_request.head.sha }})\", \"isCommit\": true}" > assets/release.json - name: Download Generated Sounds map run: node scripts/downloadSoundsMap.mjs - name: Build Project Artifacts run: vercel build --token=${{ secrets.VERCEL_TOKEN }} env: CONFIG_JSON_SOURCE: BUNDLED LOCAL_CONFIG_FILE: config.mcraft-only.json - name: Copy playground files run: | mkdir -p .vercel/output/static/playground pnpm build-playground cp -r renderer/dist/* .vercel/output/static/playground/ - name: Write pr redirect index.html run: | mkdir -p .vercel/output/static/pr echo "" > .vercel/output/static/pr/index.html - name: Write commit redirect index.html run: | mkdir -p .vercel/output/static/commit echo "" > .vercel/output/static/commit/index.html - name: Deploy Project Artifacts to Vercel uses: mathiasvr/command-output@v2.0.0 with: run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} id: deploy - uses: mshick/add-pr-comment@v2 # if: github.event_name == 'issue_comment' with: allow-repeats: true message: | Deployed to Vercel Preview: ${{ steps.deploy.outputs.stdout }} [Playground](${{ steps.deploy.outputs.stdout }}/playground/) [Storybook](${{ steps.deploy.outputs.stdout }}/storybook/) # - run: git checkout next scripts/githubActions.mjs - name: Set deployment alias if: ${{ steps.alias.outputs.alias != '' && steps.alias.outputs.alias != 'mcraft.fun' && steps.alias.outputs.alias != 's.mcraft.fun' }} run: | for alias in $(echo ${{ steps.alias.outputs.alias }} | tr "," "\n"); do vercel alias set ${{ steps.deploy.outputs.stdout }} $alias --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro done