Skip to content

Commit a8fdd57

Browse files
deployment: add ci workflow to build base docker image
1 parent bc24421 commit a8fdd57

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Base-Image-Builder
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: "Version tag for the image (e.g. v0.0.1). Always pushed."
9+
required: true
10+
type: string
11+
tag_latest:
12+
description: "Also tag this build as 'latest'. When false, only the version tag is pushed."
13+
required: false
14+
default: true
15+
type: boolean
16+
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
env:
22+
REGISTRY: ghcr.io
23+
REPO_NAME: ${{ github.repository }}
24+
25+
jobs:
26+
docker-build-push:
27+
runs-on: namespace-profile-small-ubuntu-24-04-amd64
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v6
32+
33+
# Login to a Docker registry except on PR
34+
# https://github.com/docker/login-action
35+
- name: Login to registry ${{ env.REGISTRY }}
36+
uses: docker/login-action@v2.1.0
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
logout: true
42+
43+
# Extract metadata (tags, labels) for Docker
44+
# https://github.com/docker/metadata-action
45+
- name: Extract Docker metadata
46+
id: meta
47+
uses: docker/metadata-action@v6.1.0
48+
with:
49+
images: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/ci-base
50+
tags: |
51+
# Immutable version tag, pushed on every build.
52+
type=raw,value=${{ inputs.version }}
53+
# Moving 'latest' tag, re-points to this build when enabled.
54+
type=raw,value=latest,enable=${{ inputs.tag_latest }}
55+
56+
# Build and push Docker image with Buildx
57+
# https://github.com/docker/build-push-action
58+
- name: Build and push Docker image
59+
uses: docker/build-push-action@v7.2.0
60+
with:
61+
context: .
62+
file: deployments/images/base/Dockerfile
63+
push: true
64+
tags: ${{ steps.meta.outputs.tags }}
65+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)