4

According to GitHub Docs, one can use GitHub CLI commands in a workflow.

I am trying to programmatically update the description of the repository from a workflow in that repository, and the only solution I found was using the GitHub CLI:

name: update repo 
on: push
jobs:
  update:
    runs-on: ubuntu-latest
    permissions: write-all
    steps:
      - name: 'Checkout repository'
        uses: actions/checkout@v3

      - name: 'Update repository description'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: gh repo edit --description "test"

but even with permissions: write-all, I still get the error:

HTTP 403: Resource not accessible by integration
4
  • 1
    This might be something you can't to with GITHUB_TOKEN, and you need to use a personal access token instead. Commented Aug 3, 2023 at 16:55
  • @BenjaminW. Yeah just checked; you can do it with a personal access token with "Administration" permission for the repo. I wonder if there is a way around that. Commented Aug 3, 2023 at 17:24
  • I don't think you can get away with less permissions than Admin/write on the repo, see this list. You can at least create a fine-grained access token that's scoped to just that one repo, instead of read/write on everything in the org, as the legacy PAT would have. Commented Aug 3, 2023 at 17:37
  • @BenjaminW. no I meant not having to create a personal access token, but apparently there is no way. Commented Aug 3, 2023 at 19:35

1 Answer 1

2

According to the docs you need to set GH_TOKEN not GITHUB_TOKEN

For example:

name: Comment when opened
on:
  issues:
    types:
      - opened
jobs:
  comment:
    runs-on: ubuntu-latest
    steps:
      - run: gh issue comment $ISSUE --body "Thank you for opening this issue!"
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          ISSUE: ${{ github.event.issue.html_url }}

https://docs.github.com/en/actions/using-workflows/using-github-cli-in-workflows

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.