php-actions / php-build

Fast builds for repositories using php-actions.
9 stars 9 forks source link

php-build tries to push docker image when GITHUB_TOKEN does not have push permissions #9

Closed vierbergenlars closed 1 year ago

vierbergenlars commented 2 years ago

I encountered this issue recently when an external contributor sent a PR to add additional PHP versions to the test matrix.

For this PR https://github.com/vierbergenlars/php-semver/pull/59, the image build fails (see https://github.com/vierbergenlars/php-semver/runs/7233328378?check_suite_focus=true#step:5:136) because the external contributor obviously does not have permission to publish the docker image to my repositories' namespace.

I think it's not necessary for the built docker image to always be pushed. When the image is used in the same step as it is built, it's enough that the image is present locally, without being pushed to the repository.

Of course, this negates the build speed gained by not rebuilding the image every time, but at least builds added by an external contributor will work. The first time that the action runs on with permissions of the repository owner, images will be pushed and used for future builds (even for external contributors)

It should be relatively simple to fix this issue, by making it optional for the docker push to succeed by putting it in an if and maybe logging a warning or by adding || exit 0 to the line.

g105b commented 2 years ago

Hi @vierbergenlars, That's a great idea for improvement. I'll look into it as a quick fix.

coldacid commented 1 year ago

I've run into this myself, hopefully we can see it fixed soon.