Setting Deployment Status

Possible errors regarding deployment status and how to fix them.

Deployment Status Cannot Be Set

Error message in GitHub Actions logs

gh: Resource not accessible by integration (HTTP 403)
{"message":"Resource not accessible by integration","documentation_url":"https://docs.github.com/rest/deployments/statuses#create-a-deployment-status","status":"403"}.

Solution

This means that the user running the GitHub Action does not have the required permissions to set the deployment status. The job executing the action to set the deployment status needs deployments: write under the permissions key.

Example:

name: Deploy
on:
  deployment:

jobs:
  set-state-in-progress:
    runs-on: ubuntu-latest

    # Probably this is missing:
    permissions:
      deployments: write

    steps:
      - uses: and-action/action-set-deployment-status@v1
        with:
          environment: ${{ github.event.deployment.environment }}
          state: in_progress