generated from grafana/grafana-starter-datasource-backend
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Address docker images for PRs failing to build for external PRs #737
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use the following command to run this PR with Docker at http://localhost:3000:
|
asimpson
changed the title
migrate to github registry for images
Address docker images for PRs failing to build for external PRs
Mar 1, 2024
asimpson
force-pushed
the
simpson-ghcr-pr
branch
from
March 1, 2024 16:51
9edf374
to
02d358b
Compare
asimpson
force-pushed
the
simpson-ghcr-pr
branch
from
March 1, 2024 16:57
02d358b
to
d9ab89e
Compare
aangelisc
reviewed
Mar 1, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, a couple questions:
- Is it possible to remove the condition on the build step and then only add a condition for the push? Can build and push be separated? It'll probably make the workflow more readable.
- Shall we add a PR comment detailing that the image has been saved as an artifact and how to run it?
Good questions!
|
aangelisc
approved these changes
Mar 11, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently we build a Docker image and push it to Docker Hub for every PR (#496). This works great. However, this doesn't work for PRs from external forks (example failed run) since secrets are not passed to Github Actions in that context.
There are two things to fix:
Prevent PRs from public forks from trying to build and push the image.
Come up with a workaround for PRs from external forks so that someone reviewing theh PR can easily spin up a Docker image.
The first point is easy enough to fix by only attempting to push to Dockerhub if the PR is not from a fork.
The second is more difficult and ramps up the complexity.
I previously attempted to migrate to Github Container Registry since that uses the
GITHUB_TOKEN
which is the only secret that is available in PRs from external forks. However that case only allowsread
access.The solution I've settled on is to use
docker save
to generate a tarball of the image and then persist that as an artifact. The steps to use that artifact locally are then:docker load
to load the tarfile as a Docker image, e.g.docker load < /path/to/image.tar
docker run -p 3000:3000 imagename