Skip to content

Publish a Docker test image :pr-<number> for each pull request - #175

Merged
wimaha merged 2 commits into
mainfrom
ci/pr-docker-image
Oct 19, 2026
Merged

wimaha merged 2 commits into
mainfrom
ci/pr-docker-image

Conversation

@wimaha

@wimaha wimaha commented Oct 19, 2026

Copy link
Copy Markdown
Owner

What

New workflow .github/workflows/pr-image.yml: every pull request from a branch of this repository gets a multi-platform Docker image wimaha/tesla-ble-http-proxy:pr-<number> (linux/amd64, arm64, arm/v6, arm/v7). With it, an unmerged change can be tested on a Raspberry Pi with a plain docker pull instead of docker save/scp.

  • Runs on pull_request opened/synchronize/reopened, only when head.repo.full_name == github.repository. Forks have no secrets and are skipped.
  • One concurrency group per PR: a newer push cancels an older build.
  • Builds the PR's head commit (not the merge commit with main), so the image is exactly what was pushed.
  • Only ever tags pr-<number>. :latest, :dev and version tags are never touched.
  • On close, a cleanup job deletes the tag via the Docker Hub API (404 counts as fine).

Needs checking

  • The cleanup job needs DOCKER_PASS to be a Docker Hub access token with Read, Write, Delete scope. Without it, the job fails and the tag has to be deleted by hand.
  • This PR builds its own image, so it tests the build job. The cleanup job runs when the PR is closed.

Docs

  • README: new subsection "Test images for pull requests" under "Build yourself".
  • CHANGELOG: entry under Unreleased → Added.

actionlint passes.

🤖 Generated with Claude Code

Pull requests from branches of this repository get a multi-platform image
tagged pr-<number>, rebuilt on every push (a newer push cancels an older
build). Forks are skipped since they have no secrets. Closing the pull
request deletes the tag via the Docker Hub API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🟡 Merge after the to-dos

This only adds a CI workflow and docs. The proxy code, API and the :latest image are not touched. One thing must be checked first: the Docker Hub token.

Impact on existing users: None – the change is additive. Only the new pr-<number> tags are written; :latest, :dev and version tags are not.

To-do for the author

  • Check that the DOCKER_PASS secret is a token with Read, Write, Delete scope. If not, the cleanup job fails and old pr-* tags stay on Docker Hub.
  • Make a failed Docker Hub login visible in the cleanup job (right now it ends with no clear message).

Test before merging: Let this PR build its own image, pull pr-175 on a Pi (arm) and start it. Then close the PR and check that the tag is gone.

Technical details
  • .github/workflows/pr-image.yml (cleanup step): the login curl uses -sf. If login fails, token is empty or the script stops silently. Add a check like [ -n "$token" ] || { echo "Docker Hub login failed"; exit 1; }. Also consider echo "::add-mask::$token".
  • Same file: a same-repo branch runs its own copy of the workflow with the Docker secrets. Only people with write access can do this, so the risk is low. Just be aware that any collaborator can publish tags into the production image repo. A separate repo or a separate token would limit this.
  • The concurrency group is shared by build and cleanup. Closing a PR cancels a running build, which is the wanted result.
  • Not verified: the real scope of DOCKER_PASS, and whether the arm/v6 build works on ubuntu-latest in time. I could not run the workflow.

Mask the token, and give the cleanup job a fixed name so the skipped
check is not shown with an unexpanded expression.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wimaha
wimaha merged commit d3e5323 into main Oct 19, 2026
8 checks passed
@wimaha
wimaha deleted the ci/pr-docker-image branch October 19, 2026 08:57
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.

1 participant