From 539b08d2f9754702d4b264aeb1846c915190af17 Mon Sep 17 00:00:00 2001 From: jwgcurrie Date: Sun, 17 May 2026 00:11:05 +0100 Subject: [PATCH 1/2] add image publishing via github actions triggered by new tag --- .github/workflows/publish.yml | 77 +++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..0f2c1cf --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,77 @@ +name: Publish image + +on: + push: + tags: ['v*'] + public: + workflow_dispatch: + +permissions: + contents: read + packages: write + +env: + IMAGE: ghcr.io/action-prediction-lab/pepper-box + +jobs: + publish-tag: + # On a tag push to a public repo: build and push that one tag plus :latest. + # On a private repo: this job is skipped; the tag still exists in git. + if: | + github.event_name == 'push' && + github.event.repository.private == false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: docker/setup-buildx-action@v3 + + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + ${{ env.IMAGE }}:${{ github.ref_name }} + ${{ env.IMAGE }}:latest + cache-from: type=gha + cache-to: type=gha,mode=max + + backfill: + # On private->public flip or manual re-run: build every existing v* tag. + if: github.event_name == 'public' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push each existing v* tag + run: | + set -euo pipefail + tags=$(git tag --list 'v*' --sort=creatordate) + if [[ -z "$tags" ]]; then + echo "No v* tags found, nothing to backfill." + exit 0 + fi + for tag in $tags; do + echo "::group::$tag" + git checkout "$tag" + docker build -t "$IMAGE:$tag" . + docker push "$IMAGE:$tag" + echo "::endgroup::" + done + latest=$(echo "$tags" | tail -1) + docker tag "$IMAGE:$latest" "$IMAGE:latest" + docker push "$IMAGE:latest" From 6727ee271d20fc58000331a432c1e2de7e78da7e Mon Sep 17 00:00:00 2001 From: jwgcurrie Date: Sun, 17 May 2026 00:18:18 +0100 Subject: [PATCH 2/2] add ci workflow (build only) --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3cee359 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: CI + +on: + pull_request: + branches: [main] + push: + branches: [main] + +permissions: + contents: read + +jobs: + build: + # Confirms the Dockerfile still builds. + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: docker/setup-buildx-action@v3 + + - uses: docker/build-push-action@v5 + with: + context: . + push: false + cache-from: type=gha + cache-to: type=gha,mode=max