githubgithub-actionsrenovate

check access toke is valid with github action


In Github I have created a personal access token in https://github.com/settings/tokens

Than added it to https://github.com/myrepo/settings/secrets/actions Repository secrets

with full repo rights

enter image description here

I tried to run a renovate bot action

jobs:
renovate:
    runs-on: ubuntu-latest
    steps:
    - name: Show Repo
        env:
        GH_REPO: ${{ github.repository }}
        run: echo "run on $GH_REPO"
    - name: Checkout
        uses: actions/checkout@v3.5.3
    - name: Self-hosted Renovate
        env:
        REPO_TOKEN: ${{ secrets.RENOVATE_TOKEN  }}
        uses: renovatebot/github-action@v39.0.1
        with:
        token: "$REPO_TOKEN"

which fails with

"Authentication failure"

I tried to check with curl

curl -v -H 'Authorization: token <my token>' 'https://github.com/<my-repo>'

but didn't get any insights

Is there a way to actually use that secret in an action (or with curl) to check if it has valid acces for repository maintenance ?


Solution

  • Update:

    Since you are using self-hosted renovate bot, you need to set the two envs as well:

    RENOVATE_AUTODISCOVER: true
    RENOVATE_AUTODISCOVER_FILTER: "renovate-try/*"
    

    When you enable autodiscover, by default, Renovate runs on every repository that the bot account can access. You can limit which repositories Renovate can access by using the autodiscoverFilter config option.

    https://docs.renovatebot.com/self-hosted-configuration/#autodiscover


    Have fixed your workflow file:

    jobs:
      renovate:
        runs-on: ubuntu-latest
        steps:
          - name: Show Repo
            run: echo "run on ${{ github.repository }}"
          - name: Checkout
            uses: actions/checkout@v3.5.3
          - name: Self-hosted Renovate
            uses: renovatebot/github-action@v39.0.1
            with:
              token: ${{ secrets.RENOVATE_TOKEN }}
    

    1. I have simplified your workflow yaml file.

    2. Removed the need for env.REPO_TOKEN since you can directly access the secrets.RENOVATE_TOKEN. The same for GH_REPO.

    3. Fixed your workflow formatting as well.


    Another issue might be that your secrets.RENOVATE_TOKEN do not have the necessary permission to do this action.

    You need to create a Personal access tokens (classic) here: https://github.com/settings/tokens

    You'll need atleast repo:public_repo scope for public repos, and repo scope for private repos.