Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
77 changes: 77 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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"
Loading