forked from kanidm/kanidm
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (73 loc) · 2.58 KB
/
docker_build_kanidm.yml
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
name: Container - Kanidm
# This is always built and uploads an OCI image as a build artifact, but only
# pushes to "ghcr.io/kanidm/kanidm:devel" when on "kanidm/kanidm@master".
"on":
pull_request:
push:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
set_tag_values:
runs-on: ubuntu-latest
name: Set image tag values
steps:
- id: step1
run: |
echo "OWNER_LC=${OWNER,,}" >> "${GITHUB_OUTPUT}"
env:
OWNER: '${{ github.repository_owner }}'
- id: step2
run: |
echo "REF_NAME=$(echo ${REF_NAME,,} | awk -F/ '{print $1}')" >> "${GITHUB_OUTPUT}"
env:
REF_NAME: '${{ github.ref_name }}'
outputs:
owner_lc: ${{ steps.step1.outputs.OWNER_LC }}
ref_name: ${{ steps.step2.outputs.REF_NAME }}
kanidm_build:
name: Build kanidm Docker image
runs-on: ubuntu-latest
needs:
- set_tag_values
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build kanidm
uses: docker/build-push-action@v6
with:
platforms: "linux/amd64"
tags: ghcr.io/${{ needs.set_tag_values.outputs.owner_lc }}/kanidm:devel,ghcr.io/${{ needs.set_tag_values.outputs.owner_lc }}/kanidm:${{ needs.set_tag_values.outputs.ref_name}}
build-args: |
"KANIDM_FEATURES="
file: tools/Dockerfile
# Must use OCI exporter for multi-arch: https://github.com/docker/buildx/pull/1813
outputs: type=oci,dest=/tmp/kanidm-docker.tar
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: kanidm-docker
path: /tmp/kanidm-docker.tar
kanidm_push:
name: Push kanidm Docker image
# This step is split so that we don't apply "packages: write" permission
# except when uploading the final Docker image to GHCR.
runs-on: ubuntu-latest
if: ( github.ref_type == 'tag' || github.ref == 'refs/heads/master' ) && github.repository == 'kanidm/kanidm'
needs: kanidm_build
permissions:
packages: write
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: kanidm-docker
path: /tmp
- name: Push image to GHCR
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | \
oras login -u "${{ github.actor }}" --password-stdin ghcr.io
oras copy --from-oci-layout "/tmp/kanidm-docker.tar:devel" \
"ghcr.io/${{ github.repository_owner }}/kanidm:devel"