vercel-action
vercel-action copied to clipboard
Alias domain - Error! You don't have access to the domain platform.example.com under team-shared.
When this action runs:
deployment.yml
name: Vercel Deployment
on:
push:
branches: [ 'staging' ]
env:
FONTAWESOME_NPM_AUTH_TOKEN: some-token
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build w node@16
uses: actions/setup-node@v3
with:
node-version: '14.19.3'
# cache: 'npm'
# cache-dependency-path: package-lock.json
- run: |
npm ci
npm run build
- uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN}}
# vercel-args: '--prod'
vercel-org-id: ${{ secrets.ORG_ID }}
vercel-project-id: ${{ secrets.PROJECT_ID }}
scope: team-shared
working-directory: ./
alias-domains: |
platform.example.com
On the domain assigning step
> npx vercel -t *** --scope team-shared alias https://platform-staging-fdlk83hsa-team-shared.vercel.app/ platform.example.com
Build fails and the output looks like this:
Vercel CLI 25.1.0
> Assigning alias platform.example.com to deployment platform-staging-fdlk83hsa-team-shared.vercel.app
Fetching domain platform.example.com under team-shared
Error! You don't have access to the domain platform.example.com under team-shared.
Error: The process '/opt/hostedtoolcache/node/14.19.3/x64/bin/npx' failed with exit code 1
I have the same issue when using the alias-domains parameter. It looks like it's related to the vercel set alias command of the Vercel CLI, I opened a discussion on the Vercel community here: https://github.com/vercel/community/discussions/953.
In the meanwhile, I fixed the issue by using the aliases REST API with a custom script:
workflow.yml
- [...]
- name: Set alias
uses: actions/github-script@v6
env:
previewUrl: ${{ steps.deploy.outputs.preview-url }}
aliasDomain: [my-alias-domain]
vercelToken: [my-vercel-token]
vercelTeamId: [my-vercel-team-id]
with:
script: |
const setAlias = require('./.github/scripts/set-alias.js');
await setAlias({ github, context });
set-alias.js
const axios = require('axios');
module.exports = async ({ github, context }) => {
const { vercelToken, previewUrl, vercelTeamId, aliasDomain } = process.env;
const deployment_url = previewUrl.replace('https://', '');
const configs = {
headers: { Authorization: `Bearer ${vercelToken}` },
};
const { data: deployment } = await axios.get(`https://api.vercel.com/v6/deployments/${deployment_url}`, configs);
await axios.post(
`https://api.vercel.com/v2/deployments/${deployment.id}/aliases?teamId=${vercelTeamId}`,
{ alias: aliasDomain },
configs,
);
};