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

Deployment works but action ends with "Error: Resource not accessible by integration" #235

Closed mickael-h closed 12 months ago

mickael-h commented 12 months ago

The deployment works but everything else fails afterwards. I tried messing with the parameters of the action but this is the best outcome I could get. Everything else that I've tried end up being asked to re-authenticate after the deployment, or the deployment would work at all.

My implementation of the action

name: Deploy preview app
on: [pull_request]

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  deploy:
    env:
      MONGODB_URI: ${{ secrets.MONGODB_URI_DEV }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - uses: amondnet/vercel-action@v25
        with:
          vercel-project-name: bmft
          vercel-token: ${{ secrets.VERCEL_TOKEN }}
          github-token: ${{ secrets.GITHUB_TOKEN }}
          vercel-org-id: ${{ secrets.VERCEL_TEAM_ID }}
          scope: ${{ secrets.VERCEL_TEAM_ID }}
          vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}}

The output from Github CI:

Run amondnet/vercel-action@v25
set environment for vercel cli
set env variable : VERCEL_ORG_ID
set env variable : VERCEL_PROJECT_ID
using scope
/usr/local/bin/npx vercel@25.1.0  -t *** -m githubCommitSha=518ae44f0987474f19b6c9048f6d46d0c7be2534 -m githubCommitAuthorName=mickael-h -m githubCommitAuthorLogin=mickael-h -m githubDeployment=1 -m githubOrg=BookMyFoodTruck -m githubRepo=bmft -m githubCommitOrg=BookMyFoodTruck -m githubCommitRepo=bmft -m githubCommitMessage="try fix 6" -m githubCommitRef=cicd/vercel-deploy-with-gha --scope ***
npm
npm 
 WARN
WARN 
 exec
exec The following package was not found and will be installed: vercel@25.1.0

 The following package was not found and will be installed: vercel@25.1.0
npm
npm 
 WARN
WARN 
 deprecated
deprecated node-pre-gyp@0.13.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future

 node-pre-gyp@0.13.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
Vercel CLI 25.1.0

Vercel CLI 25.1.0
Retrieving project…

Retrieving project…
Deploying bmft/bmft

Deploying bmft/bmft
Inspect: https://vercel.com/bmft/bmft/2daheK5XknutR25ZMieFooCtPtCH [2s]

Inspect: https://vercel.com/bmft/bmft/2daheK5XknutR25ZMieFooCtPtCH [2s]
Queued

Queued
https://bmft-265pdar3i-bmft.vercel.app/
https://bmft-265pdar3i-bmft.vercel.appbuilding/

Building
Completing

Completing
Preview: https://bmft-mickael-h-bmft.vercel.app/ [40s]

Preview: https://bmft-mickael-h-bmft.vercel.app/ [40s]
To deploy to production (bmft.vercel.app), run `vercel --prod`

To deploy to production (bmft.vercel.app), run `vercel --prod`
set preview-url output
set preview-name output
this is related issue or pull_request
find comment
Error: Resource not accessible by integration
mickael-h commented 12 months ago

Ok I found the issue. You need to grand both read and write permissions for the workflows in the repository and the organisation, if the repo is part of one. See this topic: https://github.com/orgs/community/discussions/21061

thenbe commented 8 months ago

Had a similar issue where vercel-action wasn't able to comment on the commit (it does that if the trigger was a push rather than a PR). To fix it, you have to enable write permission for contents.

permissions:
  contents: write # <-- This one
  deployments: write
  pull-requests: write

For reference, this was the logged error:

...
this is push event
find comment
previous comment not found
Error: Resource not accessible by integration