Skip to content
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

fix(gha): only push images on merge/release #180

Merged
merged 1 commit into from
Dec 31, 2024

Conversation

mac-chaffee
Copy link
Contributor

I've noticed all PRs have failing builds because the github action tries to push images to ghcr, which throws a 403 error.

After reading through https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/ , I'm pretty sure the original goal of pushing images tagged with the PR number is not possible to do securely.

The GITHUB_TOKEN used for authenticating to ghcr by default does not have write permissions, hence the 403 error. We could "fix" this by using pull_request_target, but that is very insecure since anyone could fork the repo and use the GITHUB_TOKEN inside the pipeline to overwrite any image in ghcr (or worse).

So since there's no secure way (as far as I know) to allow pushing to ghcr in the context of PRs, I disabled it.

Now, PRs will just trigger the linting and testing steps. Merges to main and tag pushes will still trigger builds.

Copy link
Member

@neurosnap neurosnap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@neurosnap neurosnap merged commit e924593 into picosh:main Dec 31, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants