aevea / commitsar

Tool to check that commits comply with conventional commit standard
https://commitsar.aevea.ee
MIT License
134 stars 19 forks source link

Pull request pipeline failing with "no linked PullRequests found" in GitHub Actions #512

Closed mikael-andersson91 closed 1 year ago

mikael-andersson91 commented 1 year ago

I am currently using version 0.20.2 of the Commitsar GitHub Action, and I'm attempting to use the pull request pipeline to enforce conventional commit standards on pull requests. I am consistently getting these errors when running it:

⨯ pipeline: commit-pipeline, error: reference not found ⨯ pipeline: pr-pipeline, error: no linked PullRequests found

GitHub Actions workflow file: https://github.com/mikael-andersson91/pull-request-management/blob/main/.github/workflows/pr-management.yml#L29

  commitsar: 
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Commitsar Action
        uses: aevea/commitsar@v0.20.2
        with:
          config: ${{ github.workspace }}/.commitsar.yaml
        env:
            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Example pull request: https://github.com/mikael-andersson91/pull-request-management/pull/23

Config file: https://github.com/mikael-andersson91/pull-request-management/blob/main/.commitsar.yaml

version: 1
verbose: true
commits:
  strict: true
  disabled: false
pull_request:
  conventional: true

Example job: https://github.com/mikael-andersson91/pull-request-management/actions/runs/5444549809/jobs/9902551100?pr=23 image

Is there a bug here or am I just missing something obvious here?

Also, is it possible to run this with a configuration utilizing both the pull_request and commits pipelines at the same time? The usecase being for a team just getting used to conventional commits, where a squash merge on the pull request would give a conventional commit compliant commit.

mikael-andersson91 commented 1 year ago

I missed an obvious part as noted in the documentation example for the Jira pipeline, I needed to provide ref and fetch-depth on the actions/checkout step.

  commitsar: 
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
          ref: ${{ github.event.pull_request.head.sha }}
      - name: Commitsar Action
        uses: aevea/commitsar@v0.20.2
        with:
          config: ${{ github.workspace }}/.commitsar.yaml
        env:
            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}