Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create contributors file #4

Open
samuelfernandez opened this issue Jul 16, 2022 · 5 comments
Open

Can't create contributors file #4

samuelfernandez opened this issue Jul 16, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@samuelfernandez
Copy link

Expected Behavior

It creates the svg file in the repo

Current Behavior

The creation of the contributors svg fails

Steps To Reproduce

https://github.com/ng-easy/platform/runs/7371097328?check_suite_focus=true

Error Message & Stack Trace

Error: HttpError: Could not create file: 4 of 4 required status checks are expected.

Additional Context

image

Your Environment

GitHub workflow

@samuelfernandez samuelfernandez added the bug Something isn't working label Jul 16, 2022
@jrson83
Copy link

jrson83 commented Mar 25, 2023

@samuelfernandez check the branch protection rules of your repository. I had almost the same issue, when I created a branch protection rule. I think the right way to fix is using permissions inside the workflow.

@samuelfernandez
Copy link
Author

@jrson83 Thanks for the reply. Any example of the permissions configuration? Or would you know which one exactly is needed?

@jrson83
Copy link

jrson83 commented Mar 25, 2023

@samuelfernandez give me a minute, I just saw my workflow failed again. I will reply when I know how to fix it 😁

@jrson83
Copy link

jrson83 commented Mar 25, 2023

hmm I don't know. This action just uses commit and has just one option noCommit to disable commit. Since there is no option to create a PR, I don't know if this is possible. I tried something like this, but I just get the error:

Error: HttpError: Could not update file: Changes must be made through a pull request.

The only rule I have set is Require a pull request before merging and I have enabled actions to create and approve pull requests.
@wow-actions, do you know a solution?

@jrson83
Copy link

jrson83 commented Mar 27, 2023

@samuelfernandez I got it working by setting the option noCommit: true and then run peter-evans/create-pull-request action. Here is the complete action:

name: Contributors List

on:
  workflow_dispatch:
  
  schedule:
    - cron: "0 3 */2 * *"

jobs:
  contributors:
    permissions:
      contents: write
      pull-requests: write

    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
        with:
          fetch-depth: 0
          ref: ${{ github.event.repository.default_branch }}
          
      - name: Update contributors list
        uses: wow-actions/contributors-list@b9e91f91a51a55460fdcae64daad0cb8122cdd53 # v1.1.0
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          svgPath: .github/assets/CONTRIBUTORS.svg
          round: true
          includeBots: false
          noCommit: true
      
      - name: Commit & PR
        uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54 # v4.2.4
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          add-paths: .github/assets/CONTRIBUTORS.svg
          commit-message: 'chore(): update contributors-list'
          committer: GitHub <[email protected]>
          author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
          signoff: false
          branch: workflow/update-contributors-list
          base: main
          delete-branch: true
          title: 'chore(): update contributors-list'
          body: |
            Automated update to `.github/assets/CONTRIBUTORS.svg`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants