docker / build-push-action

GitHub Action to build and push Docker images with Buildx
https://github.com/marketplace/actions/build-and-push-docker-images
Apache License 2.0
4.28k stars 548 forks source link

Can't push to ghcr on a pull request #870

Closed localagi closed 1 year ago

localagi commented 1 year ago

Troubleshooting

Before submitting a bug report please read the Troubleshooting doc.

=> Thanks, i added the debug flag

Behaviour

Steps to reproduce this issue

  1. have a project with a docker build push action on the workflow
  2. enable the runs on pull requests
  3. have a pull request, the build push action fails with 403

Expected behaviour

The push works with the tag :pr-123 into the target repository

Actual behaviour

Login into registry works with ${github.actor} Push should go to target repository, but fails. Error: buildx failed with: ERROR: failed to solve: failed to push ghcr.io/josh-xt/agixt:pr-499: unexpected status: 403 Forbidden

Configuration

https://github.com/Josh-XT/AGiXT/actions/runs/5111667183/jobs/9188888271?pr=499

https://github.com/Josh-XT/AGiXT/blob/main/.github/workflows/publish-docker.yml

https://github.com/localagi/AI-pipeline/blob/main/.github/workflows/operation-docker-build-publish.yml

logs_2922.zip

vfiset commented 1 year ago

setting this in the docker build env might help

crazy-max commented 1 year ago

https://github.com/Josh-XT/AGiXT/actions/runs/5111667183/jobs/9188888271?pr=499

Don't think this is related but the build push action is not configured properly: https://github.com/Josh-XT/AGiXT/actions/runs/5111667183/jobs/9188888271?pr=499#step:15:1

image

buildkitd-flags does not exist in this action: https://github.com/localagi/AI-pipeline/blob/3007b9776a982006265c1fb85622248c86a6bd25/.github/workflows/operation-docker-build-publish.yml#L214

Should be done in setup-buildx-action: https://github.com/docker/setup-buildx-action#inputs

The push works with the tag :pr-123 into the target repository

Doesn't look possible from a public forked repo as stipulated in GitHub docs. See "Maximum access for pull requests from public forked repositories": https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token.