Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias domain - Error! You don't have access to the domain platform.example.com under team-shared. #167

Open
xcfw opened this issue Jul 11, 2022 · 1 comment

Comments

@xcfw
Copy link

xcfw commented Jul 11, 2022

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
@cgero-eth
Copy link

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: vercel/community#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,
    );
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants