|
| 1 | +--- |
| 2 | +name: Build docker images |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - develop |
| 8 | + tags: |
| 9 | + - "*" |
| 10 | + |
| 11 | +jobs: |
| 12 | + docker: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: read |
| 16 | + packages: write |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v6 |
| 19 | + |
| 20 | + - name: Set up QEMU |
| 21 | + uses: docker/setup-qemu-action@v4 |
| 22 | + |
| 23 | + - name: Set up Docker Buildx |
| 24 | + uses: docker/setup-buildx-action@v4 |
| 25 | + |
| 26 | + - name: Login to GHCR |
| 27 | + uses: docker/login-action@v4 |
| 28 | + with: |
| 29 | + registry: ghcr.io |
| 30 | + username: ${{ github.actor }} |
| 31 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + |
| 33 | + - name: Docker meta (API) |
| 34 | + id: meta-api |
| 35 | + uses: docker/metadata-action@v6 |
| 36 | + with: |
| 37 | + images: ghcr.io/os2display/display-api-service |
| 38 | + tags: | |
| 39 | + # develop branch → 'develop' |
| 40 | + type=ref,event=branch |
| 41 | + # any tag → tag literal (e.g. '3.0.0', '3.0.0-RC1' for release |
| 42 | + # candidates cut from release/X.Y.Z) |
| 43 | + type=ref,event=tag |
| 44 | + # also emit canonical semver tag for valid semver-shaped tags, |
| 45 | + # so '3.0.0' and '3.0.0-RC1' both produce a properly-typed entry. |
| 46 | + type=semver,pattern={{version}} |
| 47 | + # latest=auto adds ':latest' only for non-prerelease semver tags, |
| 48 | + # so '3.0.0' updates ':latest' but '3.0.0-RC1' does not. |
| 49 | + flavor: | |
| 50 | + latest=auto |
| 51 | +
|
| 52 | + - name: Build and push (API) |
| 53 | + uses: docker/build-push-action@v7 |
| 54 | + with: |
| 55 | + context: ./infrastructure/display-api-service/ |
| 56 | + file: ./infrastructure/display-api-service/Dockerfile |
| 57 | + build-contexts: | |
| 58 | + repository-root=. |
| 59 | + # Use the version computed by docker/metadata-action so APP_VERSION |
| 60 | + # matches the image tag for every trigger ('develop' / '3.0.0' / |
| 61 | + # '3.0.0-RC1') without bespoke string handling per trigger. |
| 62 | + build-args: | |
| 63 | + APP_VERSION=${{ steps.meta-api.outputs.version }} |
| 64 | + APP_RELEASE_VERSION=${{ steps.meta-api.outputs.version }} |
| 65 | + APP_RELEASE_TIMESTAMP=${{ github.run_number }} |
| 66 | + push: true |
| 67 | + tags: ${{ steps.meta-api.outputs.tags }} |
| 68 | + labels: ${{ steps.meta-api.outputs.labels }} |
| 69 | + provenance: mode=max |
| 70 | + sbom: true |
| 71 | + platforms: linux/amd64,linux/arm64 |
| 72 | + # mode=max caches builder stages (client_app_builder, api_app_builder), |
| 73 | + # which is what makes multi-arch builds practical to cache at all. |
| 74 | + # Scoped per image so API and Nginx caches don't evict each other. |
| 75 | + cache-from: type=gha,scope=display-api-service |
| 76 | + cache-to: type=gha,mode=max,scope=display-api-service |
| 77 | + |
| 78 | + - name: Docker meta (Nginx) |
| 79 | + id: meta-nginx |
| 80 | + uses: docker/metadata-action@v6 |
| 81 | + with: |
| 82 | + images: ghcr.io/os2display/display-api-service-nginx |
| 83 | + tags: | |
| 84 | + # develop branch → 'develop' |
| 85 | + type=ref,event=branch |
| 86 | + # any tag → tag literal (e.g. '3.0.0', '3.0.0-RC1' for release |
| 87 | + # candidates cut from release/X.Y.Z) |
| 88 | + type=ref,event=tag |
| 89 | + # also emit canonical semver tag for valid semver-shaped tags, |
| 90 | + # so '3.0.0' and '3.0.0-RC1' both produce a properly-typed entry. |
| 91 | + type=semver,pattern={{version}} |
| 92 | + flavor: | |
| 93 | + latest=auto |
| 94 | +
|
| 95 | + - name: Build and push (Nginx) |
| 96 | + uses: docker/build-push-action@v7 |
| 97 | + with: |
| 98 | + context: ./infrastructure/nginx/ |
| 99 | + file: ./infrastructure/nginx/Dockerfile |
| 100 | + build-contexts: | |
| 101 | + repository-root=. |
| 102 | + build-args: | |
| 103 | + APP_VERSION=${{ steps.meta-nginx.outputs.version }} |
| 104 | + APP_RELEASE_VERSION=${{ steps.meta-nginx.outputs.version }} |
| 105 | + APP_RELEASE_TIMESTAMP=${{ github.run_number }} |
| 106 | + push: true |
| 107 | + tags: ${{ steps.meta-nginx.outputs.tags }} |
| 108 | + labels: ${{ steps.meta-nginx.outputs.labels }} |
| 109 | + provenance: mode=max |
| 110 | + sbom: true |
| 111 | + platforms: linux/amd64,linux/arm64 |
| 112 | + cache-from: type=gha,scope=display-api-service-nginx |
| 113 | + cache-to: type=gha,mode=max,scope=display-api-service-nginx |
0 commit comments