amondnet / vercel-action

This action make a deployment with github actions instead of Vercel builder.
https://vercel.com/docs/cli
MIT License
619 stars 95 forks source link

Attempting to deploy to staging from a workflow triggered by repository_dispatch #259

Open jeromecovington opened 3 weeks ago

jeromecovington commented 3 weeks ago

The following excerpt is from a workflow that is triggered by a button click in my cms that sends a repository_dispatch event with a config-environment prop to my repo. Therefore, the workflow is implicitly running in the main branch where all repository_dispatch events are subscribed to, per GitHub docs. I am attempting to checkout staging and trigger a redeploy to my staging Preview domain in Vercel. But, the branch is not being picked up by Vercel as staging. In fact, what happens is it picks up a Preview build off of main (although from the latest staging commit).

  # Create an aliased deployment on pushes to staging
  deploy-staging:
    name: Staging
    # Run on pushes to the staging branch, if config-environment not set (i.e. not a redeploy)
    # or if config-environment is set to 'staging' (i.e. a redeploy to staging)
    # in which case we explicitly checkout the staging branch and deploy.
    if: ${{ (github.ref == 'refs/heads/staging' && inputs.config-environment == '') || inputs.config-environment == 'staging' }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout staging branch
        uses: actions/checkout@v2
        with:
          ref: staging
      - uses: amondnet/vercel-action@v20
        with:
          vercel-project-id: ${{ inputs.vercel-project-id }}
          vercel-token: ${{ secrets.vercel-token }}
          github-token: ${{ secrets.github-token }}
          vercel-org-id: 'team_foo'
          scope: 'team_foo'
          alias-domains: ${{inputs.vercel-project}}-{{BRANCH}}.vercel.app

Ends up creating a preview: myproject-main.vercel.app