From 062491301d90bd63ff8ca1e98f03216038cf9ad7 Mon Sep 17 00:00:00 2001 From: Dmitrii Krosh Date: Sun, 16 Aug 2026 03:32:49 +0300 Subject: [PATCH] publish container to ghcr --- .github/workflows/build-site-container.yml | 47 +++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-site-container.yml b/.github/workflows/build-site-container.yml index 8497816..206062d 100644 --- a/.github/workflows/build-site-container.yml +++ b/.github/workflows/build-site-container.yml @@ -1,8 +1,10 @@ -name: Build site container +name: Build and publish site container on: push: branches: [main] + tags: + - "v*" paths: - "site/**" - ".github/workflows/build-container.yml" @@ -14,6 +16,11 @@ on: permissions: contents: read + packages: write + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: build: @@ -23,8 +30,38 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - - name: Build container - run: docker build --tag kr0sh512-site:ci ./site + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - - name: Validate nginx configuration - run: docker run --rm kr0sh512-site:ci nginx -t + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Generate image metadata + id: metadata + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=branch + type=ref,event=tag + type=sha + + - name: Build and publish container + uses: docker/build-push-action@v6 + with: + context: ./site + platforms: linux/amd64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max