wagoid / commitlint-github-action

Lints Pull Request commits with commitlint
MIT License
358 stars 55 forks source link

Error: `You have commit messages with errors` on running action #754

Closed luizfelipemacedo closed 8 months ago

luizfelipemacedo commented 8 months ago

Problem description

When tried to run the action received the follow error You have commit messages with errors but my commit history is following the rules for convencional commit

Adicional info

My workflow file

jobs:
  lint-commits:
    name: Lint Commits
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 20

      - name: Install pnpm
        uses: pnpm/action-setup@v2
        with:
          version: 8
          run_install: false

      - name: Get pnpm store directory
        shell: bash
        run: |
          echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

      - name: Setup pnpm cache
        uses: actions/cache@v3
        with:
          path: ${{ env.STORE_PATH }}
          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
          restore-keys: |
            ${{ runner.os }}-pnpm-store-

      - name: Install dependencies
        run: pnpm i

      - uses: wagoid/commitlint-github-action@v5
        env:
          NODE_PATH: ${{ github.workspace }}/node_modules

Log received

Error: You have commit messages with errors

error trying to get list of pull request's commits
Resource not accessible by integration
HttpError: Resource not accessible by integration
    at /node_modules/@actions/github/node_modules/@octokit/request/dist-node/index.js:112:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getPullRequestEventCommits (/run.js:73:7)
Error: You have commit messages with errors

error running commitlint
Cannot read properties of undefined (reading 'map')
TypeError: Cannot read properties of undefined (reading 'map')
    at showLintResults (/run.js:[14](https://github.com/user/project-name/actions/runs/7337841315/job/19979379596#step:9:15)7:51)
carlosdaniiel07 commented 8 months ago

Looks like you're running this workflow in a pull request. Because of this you need to add the following code in your workflow YAML, like said by @totally-andre in this issue #742

permissions:
  contents: read
  pull-requests: read
wagoid commented 8 months ago

Thanks for explaining @carlosdaniiel07! Closing the issue