ci: improve aliases set

This commit is contained in:
Vitaly 2024-04-09 15:59:35 +03:00
commit 0b15ac9ba0
2 changed files with 6 additions and 2 deletions

View file

@ -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

View file

@ -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)