reviewdog / action-golangci-lint

Run golangci-lint with reviewdog
https://github.com/marketplace?type=actions&query=reviewdog
MIT License
217 stars 43 forks source link

Reviewdog crashes with error: `reviewdog: environment variable $REVIEWDOG_GITHUB_API_TOKEN is not set` #556

Closed MarvinJWendt closed 1 year ago

MarvinJWendt commented 1 year ago

Reviewdog crashes with error: reviewdog: environment variable $REVIEWDOG_GITHUB_API_TOKEN is not set

Workflow:

name: Code analysis

on: [pull_request]

jobs:
  golangci-lint:
    runs-on: ubuntu-latest
    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Linting with golangci-lint
        uses: reviewdog/action-golangci-lint@v2
        with:
          github_token: ${{ secrets.ACCESS_TOKEN }}
          reporter: github-pr-review
        env:
          REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.ACCESS_TOKEN }}

Action log: https://github.com/pterm/pterm/actions/runs/5423793140/jobs/9862524142?pr=507

shogo82148 commented 1 year ago

It is the specification of GitHub Actions. Not an issue of the action.

Your workflow is triggered from the pull request https://github.com/pterm/pterm/pull/507. The document says that these workflows don't receive any secrets.

https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#accessing-secrets

Workflows triggered using the pull_request event have read-only permissions and have no access to secrets.

Actually, your REVIEWDOG_GITHUB_API_TOKEN is empty.

https://github.com/pterm/pterm/actions/runs/5423793140/jobs/9862524142?pr=507#step:3:13

image
MarvinJWendt commented 1 year ago

Huh, that's interesting. How is this action supposed to work then with the GitHub PR review reporter, as it needs a token?

shogo82148 commented 1 year ago

see https://github.com/reviewdog/reviewdog#graceful-degradation-for-pull-requests-from-forked-repositories please