Skip to content

ci: run build-test-push on all PRs, not just same-repo#39

Open
yajo wants to merge 2 commits into
Tecnativa:masterfrom
moduon:ci-build-on-prs
Open

ci: run build-test-push on all PRs, not just same-repo#39
yajo wants to merge 2 commits into
Tecnativa:masterfrom
moduon:ci-build-on-prs

Conversation

@yajo

@yajo yajo commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Fork PRs previously skipped the build-test-push job entirely,
preventing contributors from getting build and test feedback.

Removing the same-repo restriction lets all PRs run the pipeline.
The DockerHub push step was already guarded by credential checks,
and a guard was added to the GHCR push step to prevent failures
on forks where GITHUB_TOKEN is read-only.

yajo added 2 commits June 15, 2026 09:24
Fork PRs previously skipped the build-test-push job entirely,
preventing contributors from getting build and test feedback.

Removing the same-repo restriction lets all PRs run the pipeline.
The DockerHub push step was already guarded by credential checks,
and a guard was added to the GHCR push step to prevent failures
on forks where GITHUB_TOKEN is read-only.
The GHCR push step used `||` between independent secrets:
`BOT_TOKEN || GITHUB_TOKEN` and `BOT_LOGIN || repository_owner`.
When only one `BOT_` secret was set, credentials became a mismatched
pair (e.g. BOT_TOKEN + repository_owner), causing a `denied: denied`
authentication failure from ghcr.io.

Now `&&` ensures both `BOT_TOKEN` and `BOT_LOGIN` must exist together
to be used; otherwise it falls back to the always-available and
consistent `GITHUB_TOKEN` + `github.actor` pair.

This is backwards-compatible: setups with both bot secrets keep working.
Setups with none or only one now consistently use GITHUB_TOKEN.
Comment thread .github/workflows/ci.yaml
REGISTRY_TOKEN: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
REGISTRY_USERNAME: ${{ secrets.BOT_LOGIN || github.repository_owner }}
REGISTRY_TOKEN: ${{ secrets.BOT_LOGIN && secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
REGISTRY_USERNAME: ${{ secrets.BOT_TOKEN && secrets.BOT_LOGIN || github.actor }}

@ljmnoonan ljmnoonan Jun 15, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I may be mistaken, but I believe using github.actor will cause problems when the fork belongs to an organization.
If I push to github.com/MyOrg/docker-postgres-autoconf, using github.actor will cause this action to try to push the container to ghcr.io/myusername/docker-postgres-autoconf instead of ghcr.io/myorg/docker-postgres-autoconf

Comment thread .github/workflows/ci.yaml
REGISTRY_USERNAME: ${{ env.DOCKERHUB_LOGIN }}
run: ./hooks/push
- name: Push Docker Image to GitHub Registry
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository

@ljmnoonan ljmnoonan Jun 15, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I apologize for the oversight on testing and pushing test pr images in #37
However, I do not think this step should be skipped entirely for PRs from forked repos. After all, If BOT_LOGIN and BOT_TOKEN are configured there should be no problems pushing.
To do this, we can either read these BOT credentials into env and set up a check for them when the event name is a PR like

if: github.event_name != 'pull_request' | | env.BOT_TOKEN && env.BOT_LOGIN && github.event_name = 'pull_request'

Or we can just assume that a repo accepting PRs from forks (really only this one) will always have BOT_LOGIN and BOT_TOKEN configured and will never fall back to GITHUB_TOKEN

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