|
| 1 | +# Builds and pushes multi-arch Docker images to GitHub Container Registry. |
| 2 | +# |
| 3 | +# Triggers: |
| 4 | +# - Push of a version tag (v*) → builds & pushes :vX.Y.Z + :latest |
| 5 | +# - Pull request to main → build-only (no push), validates Dockerfiles |
| 6 | +# |
| 7 | +# Images produced: |
| 8 | +# ghcr.io/<owner>/verifhir-gateway:vX.Y.Z (gateway Go binary) |
| 9 | +# ghcr.io/<owner>/verifhir-gateway:latest |
| 10 | +# ghcr.io/<owner>/verifhir-web:vX.Y.Z (React UI via nginx) |
| 11 | +# ghcr.io/<owner>/verifhir-web:latest |
| 12 | +# |
| 13 | +# Architectures: linux/amd64, linux/arm64 |
| 14 | + |
| 15 | +name: Docker |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + tags: |
| 20 | + - "v*" |
| 21 | + pull_request: |
| 22 | + branches: |
| 23 | + - main |
| 24 | + |
| 25 | +env: |
| 26 | + REGISTRY: ghcr.io |
| 27 | + GATEWAY_IMAGE: ghcr.io/${{ github.repository_owner }}/verifhir-gateway |
| 28 | + WEB_IMAGE: ghcr.io/${{ github.repository_owner }}/verifhir-web |
| 29 | + |
| 30 | +jobs: |
| 31 | + build-gateway: |
| 32 | + name: Gateway image |
| 33 | + runs-on: ubuntu-latest |
| 34 | + permissions: |
| 35 | + contents: read |
| 36 | + packages: write |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout |
| 40 | + uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - name: Set up QEMU (for ARM64 emulation) |
| 43 | + uses: docker/setup-qemu-action@v3 |
| 44 | + |
| 45 | + - name: Set up Docker Buildx |
| 46 | + uses: docker/setup-buildx-action@v3 |
| 47 | + |
| 48 | + - name: Log in to GHCR |
| 49 | + if: github.event_name != 'pull_request' |
| 50 | + uses: docker/login-action@v3 |
| 51 | + with: |
| 52 | + registry: ${{ env.REGISTRY }} |
| 53 | + username: ${{ github.actor }} |
| 54 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + |
| 56 | + - name: Docker metadata (tags & labels) |
| 57 | + id: meta |
| 58 | + uses: docker/metadata-action@v5 |
| 59 | + with: |
| 60 | + images: ${{ env.GATEWAY_IMAGE }} |
| 61 | + tags: | |
| 62 | + type=semver,pattern={{version}} |
| 63 | + type=semver,pattern={{major}}.{{minor}} |
| 64 | + type=raw,value=latest,enable={{is_default_branch}} |
| 65 | +
|
| 66 | + - name: Build and push gateway |
| 67 | + uses: docker/build-push-action@v6 |
| 68 | + with: |
| 69 | + context: . |
| 70 | + file: Dockerfile |
| 71 | + platforms: linux/amd64,linux/arm64 |
| 72 | + push: ${{ github.event_name != 'pull_request' }} |
| 73 | + tags: ${{ steps.meta.outputs.tags }} |
| 74 | + labels: ${{ steps.meta.outputs.labels }} |
| 75 | + cache-from: type=gha |
| 76 | + cache-to: type=gha,mode=max |
| 77 | + |
| 78 | + build-web: |
| 79 | + name: Web image |
| 80 | + runs-on: ubuntu-latest |
| 81 | + permissions: |
| 82 | + contents: read |
| 83 | + packages: write |
| 84 | + |
| 85 | + steps: |
| 86 | + - name: Checkout |
| 87 | + uses: actions/checkout@v4 |
| 88 | + |
| 89 | + - name: Set up QEMU |
| 90 | + uses: docker/setup-qemu-action@v3 |
| 91 | + |
| 92 | + - name: Set up Docker Buildx |
| 93 | + uses: docker/setup-buildx-action@v3 |
| 94 | + |
| 95 | + - name: Log in to GHCR |
| 96 | + if: github.event_name != 'pull_request' |
| 97 | + uses: docker/login-action@v3 |
| 98 | + with: |
| 99 | + registry: ${{ env.REGISTRY }} |
| 100 | + username: ${{ github.actor }} |
| 101 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 102 | + |
| 103 | + - name: Docker metadata |
| 104 | + id: meta |
| 105 | + uses: docker/metadata-action@v5 |
| 106 | + with: |
| 107 | + images: ${{ env.WEB_IMAGE }} |
| 108 | + tags: | |
| 109 | + type=semver,pattern={{version}} |
| 110 | + type=semver,pattern={{major}}.{{minor}} |
| 111 | + type=raw,value=latest,enable={{is_default_branch}} |
| 112 | +
|
| 113 | + - name: Build and push web |
| 114 | + uses: docker/build-push-action@v6 |
| 115 | + with: |
| 116 | + context: ./web |
| 117 | + file: ./web/Dockerfile |
| 118 | + platforms: linux/amd64,linux/arm64 |
| 119 | + push: ${{ github.event_name != 'pull_request' }} |
| 120 | + tags: ${{ steps.meta.outputs.tags }} |
| 121 | + labels: ${{ steps.meta.outputs.labels }} |
| 122 | + cache-from: type=gha |
| 123 | + cache-to: type=gha,mode=max |
0 commit comments