Skip to content

Commit 2c76f56

Browse files
committed
6601: Created combined workflow for release and image build
1 parent 7673c60 commit 2c76f56

2 files changed

Lines changed: 97 additions & 109 deletions

File tree

.github/workflows/docker_build_images_from_tag.yml

Lines changed: 0 additions & 105 deletions
This file was deleted.

.github/workflows/github_build_release.yml

Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# This workflow builds a GitHub release on tag creation.
1+
# This workflow builds a GitHub release on tag creation and then builds and
2+
# pushes Docker images to GitHub Container Registry.
23

34
on:
45
push:
@@ -8,15 +9,14 @@ on:
89
name: Create Github Release
910
run-name: "Create Github Release - ${{ github.head_ref || github.ref_name }}"
1011

11-
permissions:
12-
contents: write
13-
1412
env:
1513
COMPOSE_USER: runner
1614

1715
jobs:
1816
create-release:
1917
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
2020
steps:
2121
- name: Checkout
2222
uses: actions/checkout@v4
@@ -61,3 +61,96 @@ jobs:
6161
env:
6262
GITHUB_TOKEN: ${{ github.TOKEN }}
6363
shell: bash
64+
65+
images:
66+
needs: create-release
67+
runs-on: ubuntu-latest
68+
permissions:
69+
contents: read
70+
packages: write
71+
attestations: write
72+
id-token: write
73+
env:
74+
REGISTRY: ghcr.io
75+
IMAGE_NAME_MAIN: ${{ github.repository }}
76+
IMAGE_NAME_NGINX: ${{ github.repository }}-nginx
77+
steps:
78+
- name: Checkout repository
79+
uses: actions/checkout@v5
80+
with:
81+
ref: ${{ github.ref_name }}
82+
83+
- name: Set up QEMU
84+
uses: docker/setup-qemu-action@v3
85+
86+
- name: Set up Docker Buildx
87+
uses: docker/setup-buildx-action@v3
88+
89+
- name: Log in to the Container registry
90+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
91+
with:
92+
registry: ${{ env.REGISTRY }}
93+
username: ${{ github.actor }}
94+
password: ${{ secrets.GITHUB_TOKEN }}
95+
96+
# Build main
97+
98+
- name: Docker meta (main)
99+
id: meta-main
100+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
101+
with:
102+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_MAIN }}
103+
tags: |
104+
type=raw,value=${{ github.ref_name }}
105+
106+
- name: Build and push Docker image
107+
id: push-main
108+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
109+
with:
110+
context: ./infrastructure/display-api-service/
111+
file: ./infrastructure/display-api-service/Dockerfile
112+
build-args: |
113+
APP_VERSION=${{ github.ref_name }}
114+
push: true
115+
tags: ${{ steps.meta-main.outputs.tags }}
116+
labels: ${{ steps.meta-main.outputs.labels }}
117+
provenance: mode=max
118+
sbom: true
119+
120+
- name: Generate artifact attestation
121+
uses: actions/attest-build-provenance@v3
122+
with:
123+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_MAIN}}
124+
subject-digest: ${{ steps.push-main.outputs.digest }}
125+
push-to-registry: true
126+
127+
# Build Nginx (depends on main)
128+
129+
- name: Docker meta (nginx)
130+
id: meta-nginx
131+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
132+
with:
133+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_NGINX }}
134+
tags: |
135+
type=raw,value=${{ github.ref_name }}
136+
137+
- name: Build and push Docker image
138+
id: push-nginx
139+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
140+
with:
141+
context: ./infrastructure/nginx/
142+
file: ./infrastructure/nginx/Dockerfile
143+
build-args: |
144+
APP_VERSION=${{ github.ref_name }}
145+
push: true
146+
tags: ${{ steps.meta-nginx.outputs.tags }}
147+
labels: ${{ steps.meta-nginx.outputs.labels }}
148+
provenance: mode=max
149+
sbom: true
150+
151+
- name: Generate artifact attestation
152+
uses: actions/attest-build-provenance@v3
153+
with:
154+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_NGINX}}
155+
subject-digest: ${{ steps.push-nginx.outputs.digest }}
156+
push-to-registry: true

0 commit comments

Comments
 (0)