-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build Docker image and push to GHCR #230
Conversation
This looks.. intriguing! I don't remember if I ever considered combining composite+docker actions (I did play with having two composites in the same repo in the past, though). I'll need to take some time to think about it and look through the patch more closely. Please, don't expect an immediate review, however it does look very promising at glance! Originally I thought that I'd have a workflow where I trigger a release, that release adds a commit that hardcodes an update to This looks like a better idea so far. Thanks again! |
That sounds great. Take your time. Thanks for your consideration. If you do decide to accept this change, I'm happy to help maintain the workflows in the future. Feel free to mention me @br3ndonland and I will help address any issues that come up. |
Thanks! I've hit "rebase" on the UI to get this on top of the recent changes/linting/lockfile bumps but haven't yet looked into it deeper. |
I'm done with the initial review. More is needed, but I'd rather accept what I can through separate PRs to make this one smaller. And the suggested refactoring could be done in parallel. I think that generating the file is a good idea. It should be possible to write the file without bringing in the PyYAML dependency. But it's not that easy for reading it. Can we make use of |
@webknjaz thank you for your detailed review. I've addressed most of your comments so far. |
Commits like 213c885ac41d769527ac150e2e633bb1ccd886d4 aren't really necessary since Git would automatically absorb changes applied separately. FYI. In fact, this one may have a harmful effect — when the label change is merged into the default branch, and this one rebased on top, Git will keep the removal commit and attempt deleting the label 🤷♂️ Anyway, we'll address this later on. |
@br3ndonland I'm sure my review is incomplete, but hopefully it gives you enough ideas to try out until the next time. I think it'd be nice to get this in before #236 if at all possible. |
@br3ndonland could you also rebase this branch locally? The GH button doesn't work, meaning there's going to be some conflicts to resolve. |
pypa#230 (comment) Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
for more information, see https://pre-commit.ci
At your request (#230 (comment)), the
After navigating to the action, there will be a "Run workflow" button. To publish an image for a specific release, v1.13.0 for example:
Currently the workflow will automatically build and push Docker images whenever new commits are pushed to
Why wouldn't you want to push a Docker image for
The case of
Your repo does not have any branches or tags named If you're publishing a Docker image for a specific release, enter the name of the tag as I said above.
|
Are you sure you're looking at the latest PR diff? Right now, when I look at https://github.com/pypa/gh-action-pypi-publish/pull/230/files#diff-63d86cca28be8586869affd2baf5d48489229f5d9b4684c11beb787eee6f614cR9-R14, I see a single input — Though, reading through the workflow, the docker image tag is computed from the tag input, which makes sense to me.
Oh… That's the bit I've been overlooking.
Oh, I was just writing down my confusion. I didn't look into the PR in a while, so I didn't remember all the context and got lost. It makes sense now.
This was very helpful to refresh my understanding of the bits and pieces of the updates in the PR. Thank you! I think I'm ready to merge it finally. I'll then try it out and let you know if something is still uncertain. |
I just pushed |
This is a follow-up for #230, which renamed the workflow filename.
@br3ndonland here are some regressions reported:
Could you help me figure them out? |
v1.12.1 addresses immediate problems from the list above. Long-term, the release process will need to be improved and made more cohesive. |
PR pypa#230 updated the action to pull Docker images from GHCR instead of building Docker images each time the workflow runs. As part of this PR, a new GitHub Actions workflow was added that builds Docker images and pushes them to GitHub Container Registry (GHCR). Actions can be referenced in various ways. The Docker build workflow covers most of the action references, but does not push Docker images tagged with the Git commit ID (Git SHA). This commit will add Docker tags for referencing the action with a Git SHA. GitHub Actions only supports references by the full 40 character SHA. If users try to reference the action by a short SHA like `1234567`, they will get an error like, "Unable to resolve action `pypa/gh-action-pypi-publish@1234567`, the provided ref `1234567` is the shortened version of a commit SHA, which is not supported. Please use the full commit SHA `1234567890123456789012345678901234567890` instead." pypa#230 pypa#290 https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-pre-written-building-blocks-in-your-workflow#using-shas
@webknjaz thanks for handling the user feedback so far. Here are some updates to the list you provided.
|
Description
Closes #58
Up to this point, the project has been set up as a Docker action referencing the Dockerfile.
gh-action-pypi-publish/action.yml
Lines 86 to 88 in 3fbcf7c
The downside to using the Dockerfile for the action is that the Docker image must be built every time the action is used (#58).
This PR will set up the project to build the Docker image and push it to GitHub Container Registry (GHCR). This change will speed up user workflows every time the action is used because the workflows will simply pull the Docker image from GHCR instead of building again.
Changes
Build container image with GitHub Actions
This PR will build Docker images with the Docker CLI (
docker build
). Builds will include inline cache metadata so layers can be reused by future builds.This PR only proposes to build container images for
x86_64
(linux/amd64
) because GitHub Actions Linux runners currently only supportx86_64
CPU architectures (actions/runner-images#5631), and this project only supports GitHub Actions Linux runners. The README explains:Push container image to GHCR
The workflow will log in to GHCR using the built-in GitHub token and push the Docker image. Workflow runs triggered by pull requests will build the Docker image and run the smoke tests but will not push the Docker image.
Update action to pull container image from GHCR
Docker actions support pulling in pre-built Docker images by supplying a registry address to the
image:
key. The downside to this syntax is that there's no way to specify the correct Docker tag because the GitHub Actionsimage:
anduses:
keys don't accept any context. For example, if a user's workflow hasuses: pypa/gh-action-pypi-publish@release/v1.8
, then the action should pull in a Docker image built from therelease/v1.8
ref, something likeghcr.io/pypa/gh-action-pypi-publish:release-v1.8
(Docker tags can't have/
).The workaround is to switch the top-level
action.yml
to a composite action that then calls the Docker action, substituting the correct image name and tag.Related
github.action_repository
andgithub.action_ref
are empty inrun
for composite actions actions/runner#2473