Can't auth with container registry ghcr.io

I am using this configuration and I keep getting an error that there is an issue with my code.

Error: start-build.yml (Line: 20, Col: 19): Unexpected value ‘’

[19]check_suite_focus=true#step:1:19)Error: The template is not valid. start-build.yml (Line: 20, Col: 19): Unexpected value ‘’

The YAML looks fine to me. Can you see why I can’t log into the GHCR? I was able to use the CLI and docker login with the below credentials with success.

name: Start-Build

on:
  push
permissions:
  packages: read
env:
  REGISTRY: ghcr.io
  IMAGE_NAME: ${{ github.repository }}
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  start-build:
    runs-on: ubuntu-latest
    container:
      image: ghcr.io/<REPO>/<IMAGE_NAME>:0.0.0
      credentials:
        username: "MY_USERNAME"
        password: ${{ secrets.GHCR_TOKEN }}
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2
1 Like

Maybe information from here does help: docker - Cannot pull from GitHub Packages from GitHub Actions - Stack Overflow

I’m trying to use my private container in GHCR.io to run the steps. So this example is a little different in that it is loging in on the runner. But I want the runner to run the steps using my container.

Can I log into the ghcr and then run a container. I thought the different jobs in the .GitHub runner Yaml file didn’t allow this.

1 Like

That should be possible by adding jobs.<job_id>.container.credentials with a token that allows access to the image.

That is in my configuration i initially posted. How is what you recommend different from my configuration?

Right, sorry, I confused that with the Stack Overflow link above. As for your YAML, could you point out whichever line the error message refers to, or better link the actual file? If I count in your first post line 20 is the steps: one. :sweat_smile:

Sorry about that. Line 20 is the password line in this block.

credentials:
        username: "MY_USERNAME"
        password: ${{ secrets.GHCR_TOKEN }}

I do have a secret saved called GHCR_TOKEN that is the PAT from one of my automated account.

Hm, not a lot of possible errors there. Does the username match the PAT?

Also, check the logs if the username might somehow end up including the quotes. I always use single quotes, I’m not sure how GitHub’s parser treats double quotes there.

I found the issue was that I was not required to set the GITHUB_TOKEN env. I removed that from my YAML and it worked.