-
Notifications
You must be signed in to change notification settings - Fork 3
59 lines (58 loc) · 2.04 KB
/
build-docker.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
on:
workflow_call:
inputs:
image-name:
required: true
type: string
version:
required: true
type: string
platforms:
required: false
type: string
default: "linux/amd64,linux/arm64"
working-dir:
required: true
type: string
artifact-name:
required: false
type: string
artifact-path:
required: false
type: string
jobs:
build:
name: ${{ inputs.image-name }}
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout
uses: actions/checkout@v4
- name: 📦 Download artifact
uses: actions/download-artifact@v4
if: inputs.artifact-name && inputs.artifact-path
with:
name: ${{ inputs.artifact-name }}
path: ${{ inputs.artifact-path }}
- name: 🦤 Set up qemu
uses: docker/setup-qemu-action@v3
- name: 🐳 Set up docker buildx
uses: docker/setup-buildx-action@v3
- name: 🧰 Build container image
if: github.ref != 'refs/heads/main' || inputs.version == 'dev'
working-directory: ${{ inputs.working-dir }}
run: docker buildx build --platform "${{ inputs.platforms }}" .
- name: 🔑 Login to GitHub Container registry
if: github.ref == 'refs/heads/main' && inputs.version != 'dev'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🧰 ⬆️ Build and push container image
if: github.ref == 'refs/heads/main' && inputs.version != 'dev'
working-directory: ${{ inputs.working-dir }}
run: |
docker buildx build --push --platform "${{ inputs.platforms }}" \
-t "ghcr.io/codecentric/habitcentric/${{ inputs.image-name }}:latest" \
-t "ghcr.io/codecentric/habitcentric/${{ inputs.image-name }}:$(git rev-parse --short HEAD)" \
-t "ghcr.io/codecentric/habitcentric/${{ inputs.image-name }}:${{ inputs.version }}" .