From 0b15ac9ba099c5e1183003efdbb5576e06d531bb Mon Sep 17 00:00:00 2001 From: Vitaly Date: Tue, 9 Apr 2024 15:59:35 +0300 Subject: [PATCH] ci: improve aliases set --- .github/workflows/preview.yml | 6 +++++- scripts/githubActions.mjs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 44c55480..cdefd2e2 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -49,9 +49,13 @@ jobs: Deployed to Vercel Preview: ${{ steps.deploy.outputs.stdout }} [Playground](${{ steps.deploy.outputs.stdout }}/playground.html) [Storybook](${{ steps.deploy.outputs.stdout }}/storybook/) + - run: git checkout next scripts/githubActions.mjs - name: Get deployment alias run: node scripts/githubActions.mjs getAlias id: alias + env: + ALIASES: ${{ env.ALIASES }} + PULL_URL: ${{ github.event.comment.issue.pull_request.url }} - name: Set deployment alias - if: ${{ steps.alias.outputs.alias != '' }} + if: ${{ steps.alias.outputs.alias != '' && steps.alias.outputs.alias != 'mcraft.fun' && steps.alias.outputs.alias != 's.mcraft.fun' }} run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ steps.alias.outputs.alias }} --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro diff --git a/scripts/githubActions.mjs b/scripts/githubActions.mjs index ac218f56..ba7b8566 100644 --- a/scripts/githubActions.mjs +++ b/scripts/githubActions.mjs @@ -7,7 +7,7 @@ const fns = { const aliasesRaw = process.env.ALIASES if (!aliasesRaw) throw new Error('No aliases found') const aliases = aliasesRaw.split('\n').map((x) => x.split('=')) - const githubActionsPull = process.env.GITHUB_REF.match(/refs\/pull\/(\d+)\/merge/) + const githubActionsPull = process.env.PULL_URL?.split('/').at(-1) if (!githubActionsPull) throw new Error(`Not a pull request, got ${process.env.GITHUB_REF}`) const prNumber = githubActionsPull[1] const alias = aliases.find((x) => x[0] === prNumber)