From 1016d333ccba513f7570e0ea2f1f07526463b9a1 Mon Sep 17 00:00:00 2001 From: che-pj Date: Sat, 30 Aug 2025 12:24:37 +0200 Subject: [PATCH] ci(workflows): add pr-build workflow for dev/test container images - Introduces a new GitHub Actions workflow that automatically builds and pushes multi-arch Docker images for pull requests - Images are tagged with the PR number (e.g., dev-pr-123) for easy identification - Uses GHCR as the container registry with proper authentication via GITHUB_TOKEN - Implements BuildKit cache optimization for faster builds - Supports both linux/amd64 and linux/arm64 platforms --- .github/workflows/pr-build.yml | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/pr-build.yml diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml new file mode 100644 index 0000000..f572e76 --- /dev/null +++ b/.github/workflows/pr-build.yml @@ -0,0 +1,50 @@ +name: PR Dev/Test Container + +on: + pull_request: + types: [opened, synchronize, reopened] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write # ✅ needed for GHCR push + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GHCR + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata for PR builds + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=dev-pr-${{ github.event.pull_request.number }} + + # Build and push multi-arch dev image + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max