#Has anyone successfully been able to

1 messages ยท Page 1 of 1 (latest)

edgy wedge
#

Should work fine I believe! Does the GitHub token have permissions to push to ghcr?

muted mica
#

Yes.. I believe the reason is that dagger is using Basic Auth and the Github API does not support that, i think..
I will make a test repository to test it our.

edgy wedge
muted mica
#

@edgy wedge I made an example. This is the way I would expect to configure it.

      - uses: dagger/dagger-for-github@8.0.0
        name: publish
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GH_ACTOR: ${{ github.actor }}
        with:
          call: publish-image --gh-user env://GH_ACTOR --gh-token env://GH_TOKEN
          cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
          version: "latest"
func (m *AuthTest) PublishImage(ctx context.Context, ghUser string, ghToken *dagger.Secret) (string, error) {
  return dag.Container().
    From("alpine:latest").
    WithLabel("org.opencontainers.image.source", "https://github.com/kerwood/dagger-ghcr-auth-test").
    WithRegistryAuth("ghcr.io", ghUser, ghToken).
    Publish(ctx, "ghcr.io/kerwood/dagger-ghcr-auth-test:latest")
}

https://github.com/Kerwood/dagger-ghcr-auth-test
https://github.com/Kerwood/dagger-ghcr-auth-test/actions/runs/16747698177/job/47410070073

If anyone what to test something out, the workflow is triggered by any PR.

edgy wedge
muted mica
edgy wedge
#

Interesting, everything looks like it should be right ๐Ÿค” I'll try some things on one of my repos and get back to you!

edgy wedge
muted mica
#

The thing is that if I run dagger locally from my laptop with dagger -c 'publish-image kerwood cmd://"gh auth token"' it works as intended.
I tried changing the case on the 'k' but that ended in with this error failed to push ghcr.io/Kerwood/dagger-ghcr-auth-test:latest: invalid reference format: repository name (Kerwood/dagger-ghcr-auth-test) must be lowercase

#

Same 403 error

#

Turns out Im an idiot.. Apparently you need to give the repo actions/workflows access to the package registry. Adding the permissions.packages: write property to your workflow file is not enough.
I am sorry for have wasted your time on an issue not related to Dagger.

muted mica
#

But thank you for your help figuring it out ๐Ÿ™‚