Skip to content

Commit 5996bec

Browse files
committed
build: add action to build the container image (dev)
1 parent aa57c10 commit 5996bec

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

.github/workflows/build.yaml

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

0 commit comments

Comments
 (0)