badge-readme icon indicating copy to clipboard operation
badge-readme copied to clipboard

Permissions section in .yml file needed

Open joshuabrownenz opened this issue 1 year ago • 4 comments

I created the specified update-badges.yml

name: Update badges

on:
  schedule:
    # Runs at 0am UTC every day
    - cron: "0 0 * * *"
jobs:
  update-readme:
    name: Update Readme with badges
    runs-on: ubuntu-latest
    steps:
      - name: Badges - Readme
        uses: pemtajo/badge-readme@main

But when I ran the workflow I was getting a failed action with the error message github.GithubException.GithubException: 403 {"message": "Resource not accessible by integration", "documentation_url": "https://docs.github.com/rest/repos/contents#create-or-update-file-contents"}

It looked like it was an issue with the GITHUB_TOKEN so I added the contents: write permission in the .yml and the problem went away.

name: Update badges

on:
  schedule:
    # Runs at 2am UTC
    - cron: "0 2 * * *"
jobs:
  update-readme:
    name: Update Readme with badges
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Badges - Readme
        uses: pemtajo/badge-readme@main

joshuabrownenz avatar Oct 16 '23 08:10 joshuabrownenz

I received the same error when using the example from the README and this appears to resolve the issue.

4N0NYM0U5MY7H avatar May 17 '24 02:05 4N0NYM0U5MY7H

I think you can also address this through the settings of your repository. See https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token

Look in: Settings > Actions > General > Workflow permissions

image

MathewBiddle avatar May 17 '24 12:05 MathewBiddle

I see. Default is set to read only. Thank you!

4N0NYM0U5MY7H avatar May 17 '24 15:05 4N0NYM0U5MY7H

Yup, that fixed it for me as well!

noelmiller avatar Jun 12 '24 16:06 noelmiller