Skip to content

Instantly share code, notes, and snippets.

@nmagee
Created January 9, 2026 19:12
Show Gist options
  • Select an option

  • Save nmagee/2397c3f95410c4eb895ba8a8d08ee745 to your computer and use it in GitHub Desktop.

Select an option

Save nmagee/2397c3f95410c4eb895ba8a8d08ee745 to your computer and use it in GitHub Desktop.
A sample GitHub Action file for container builds
name: container-build
on:
push:
branches: [ main ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ACCOUNT/IMAGE-NAME # replace these as needed
IMAGE_TAG: 1.${{ github.run_number }} # GITHUB_RUN_NUMBER, so versions will be 1.1, 1.2, etc.
DOCKER_BUILDKIT: 1
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}
- name: Build and Push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
provenance: false
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
ghcr.io/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment