Skip to content

Commit 75b7c76

Browse files
committed
build: add action to build the container image (dev)
1 parent fe847dd commit 75b7c76

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/build.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build dev version
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
CHART_NAME: ${{ github.repository }}/helm-chart
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
18+
cancel-in-progress: true
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
build-image:
25+
runs-on: ubuntu-24.04
26+
outputs:
27+
image: ${{ steps.docker_image.outputs.image }}
28+
image_repository: ${{ steps.docker_image.outputs.image_repository }}
29+
image_tag: ${{ steps.docker_image.outputs.image_tag }}
30+
permissions:
31+
contents: read
32+
packages: write
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
- name: Docker image metadata
37+
id: meta
38+
uses: docker/metadata-action@v5
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
tags: type=sha
42+
- name: Extract Docker image name
43+
id: docker_image
44+
env:
45+
IMAGE_TAGS: ${{ steps.meta.outputs.tags }}
46+
run: |
47+
IMAGE=$(echo "$IMAGE_TAGS" | cut -d" " -f1)
48+
IMAGE_REPOSITORY=$(echo "$IMAGE" | cut -d":" -f1)
49+
IMAGE_TAG=$(echo "$IMAGE" | cut -d":" -f2)
50+
echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
51+
echo "image_repository=$IMAGE_REPOSITORY" >> "$GITHUB_OUTPUT"
52+
echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT"
53+
- name: Set up Docker buildx
54+
uses: docker/setup-buildx-action@v3
55+
- name: Set up Docker
56+
uses: docker/login-action@v3
57+
with:
58+
registry: ${{ env.REGISTRY }}
59+
username: ${{ github.actor }}
60+
password: ${{ secrets.GITHUB_TOKEN }}
61+
- name: Build and push Docker image
62+
uses: docker/build-push-action@v6
63+
with:
64+
context: .
65+
push: true
66+
tags: ${{ steps.meta.outputs.tags }}
67+
labels: ${{ steps.meta.outputs.labels }}
68+
cache-from: type=registry,ref=${{ steps.docker_image.outputs.image_repository }}:buildcache
69+
cache-to: type=registry,ref=${{ steps.docker_image.outputs.image_repository }}:buildcache,mode=max
70+
71+
# TODO: add job to build and push the helm chart if needed (manual trigger)

0 commit comments

Comments
 (0)