Skip to content

feature/add gh action to promote docker image to registry#37

Merged
rpmcginty merged 7 commits intomainfrom
feature/add-gh-action-to-promote-docker-image-to-registry
Apr 1, 2026
Merged

feature/add gh action to promote docker image to registry#37
rpmcginty merged 7 commits intomainfrom
feature/add-gh-action-to-promote-docker-image-to-registry

Conversation

@rpmcginty
Copy link
Copy Markdown
Collaborator

@rpmcginty rpmcginty commented Apr 1, 2026

What's in this Change?

Adds a new GitHub Actions workflow to build and publish a Docker image to GitHub Container Registry (GHCR), with publishing gated on successful completion of the existing “Build and Test” workflow for main and direct publishing for version tags / manual dispatch.

This will help simplify consuming the docker image directly instead of having to rebuild

Changes:

  • Introduces .github/workflows/publish_docker.yml to build and push a Docker image to ghcr.io.
  • Uses workflow_run to gate publishing on successful test workflow completion for main.
  • Adds Docker metadata-based tagging and GitHub Actions cache configuration for faster rebuilds.

Testing

  • Build step is included in PR checks (run only after build and test succeeds)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.79%. Comparing base (af2c23a) to head (ca4172e).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #37   +/-   ##
=======================================
  Coverage   90.79%   90.79%           
=======================================
  Files          26       26           
  Lines        1412     1412           
  Branches      131      131           
=======================================
  Hits         1282     1282           
  Misses         94       94           
  Partials       36       36           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new GitHub Actions workflow to build and publish a Docker image to GitHub Container Registry (GHCR), with publishing gated on successful completion of the existing “Build and Test” workflow for main and direct publishing for version tags / manual dispatch.

Changes:

  • Introduces .github/workflows/publish_docker.yml to build and push a Docker image to ghcr.io.
  • Uses workflow_run to gate publishing on successful test workflow completion for main.
  • Adds Docker metadata-based tagging and GitHub Actions cache configuration for faster rebuilds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/publish_docker.yml Outdated

steps:
- name: Checkout repository
uses: actions/checkout@v4
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

For workflow_run events, actions/checkout defaults to the repository’s default branch HEAD at run time, not the SHA that was actually tested. This can result in publishing an image for a different commit than the one that triggered the successful “Build and Test” run. Consider checking out github.event.workflow_run.head_sha when github.event_name == 'workflow_run' (and falling back to github.sha for other triggers).

Suggested change
uses: actions/checkout@v4
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

will fix this

Comment on lines +84 to +89
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

Because this workflow is triggered via workflow_run, runs can complete out of order (an older main commit’s tests may finish after a newer one). With latest enabled on the default branch, a late publish from an older SHA can overwrite the latest tag with an older image. To avoid this, add a guard that only publishes latest (or publishes at all) when the workflow_run.head_sha matches the current HEAD of main (e.g., compare against refs/heads/main via git ls-remote/GitHub API), or otherwise skip/cancel stale runs.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I will add concurrency with cancel-in-progress set to true

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/publish_docker.yml
Comment thread .github/workflows/publish_docker.yml
Comment thread .github/workflows/publish_docker.yml Outdated
# For workflow_run events, checkout the SHA that was actually tested,
# not the current HEAD (which may have moved). For other events, use github.sha.
- name: Checkout repository
uses: actions/checkout@v4
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We may want to bump the version we use to the latest?

https://github.com/actions/checkout

Comment thread .github/workflows/publish_docker.yml Outdated

# Buildx enables advanced features like caching and multi-platform builds.
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here, v4 looks to be newest?

https://github.com/docker/setup-buildx-action

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

sounds good

@rpmcginty rpmcginty requested a review from njmei April 1, 2026 19:34
Copy link
Copy Markdown

@mardoum mardoum left a comment

Choose a reason for hiding this comment

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

Not sure but Allen repo auth step might not be necessary, either way probably doesn't hurt anything. Looks good.

Comment on lines +37 to +39
concurrency:
group: docker-publish-${{ github.event.workflow_run.head_branch || github.ref_name }}
cancel-in-progress: true
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I didn't know about this mechanism -- cool

Comment on lines +73 to +77
- name: Set up AllenInstitute Repo Authorization
uses: ./.github/actions/configure-org-repo-authorization
with:
token: ${{ secrets.AI_PACKAGES_TOKEN }}
ssh_private_key: ${{ secrets.AIBSGITHUB_PRIVATE_KEY }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I didn't seem to need this when I wrote a similar workflow.

@rpmcginty rpmcginty merged commit 90ab548 into main Apr 1, 2026
9 checks passed
@rpmcginty rpmcginty deleted the feature/add-gh-action-to-promote-docker-image-to-registry branch April 1, 2026 22:58
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.

4 participants