2022-06-20 12:16:55 +02:00
|
|
|
---
|
|
|
|
name: Container - Kanidmd
|
|
|
|
|
2023-07-18 01:03:04 +02:00
|
|
|
# This is always built and uploads an OCI image as a build artifact, but only
|
2023-09-06 02:25:30 +02:00
|
|
|
# pushes to "ghcr.io/kanidm/kanidmd:devel" when on "kanidm/kanidm@master".
|
2023-10-26 03:48:58 +02:00
|
|
|
"on":
|
2022-06-21 02:16:00 +02:00
|
|
|
pull_request:
|
2022-06-20 12:16:55 +02:00
|
|
|
push:
|
|
|
|
|
2022-11-13 23:57:05 +01:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
2023-07-18 01:03:04 +02:00
|
|
|
|
2022-06-20 12:16:55 +02:00
|
|
|
jobs:
|
2022-07-05 03:39:38 +02:00
|
|
|
kanidmd_build:
|
2023-07-18 01:03:04 +02:00
|
|
|
name: Build kanidmd Docker image
|
2022-06-20 12:16:55 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-09-06 02:25:30 +02:00
|
|
|
- uses: actions/checkout@v4
|
2023-07-18 01:03:04 +02:00
|
|
|
- name: Set up Docker Buildx
|
2023-09-17 22:30:40 +02:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2024-01-16 02:30:52 +01:00
|
|
|
- name: Docker metadata
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
with:
|
|
|
|
# list of Docker images to use as base name for tags
|
|
|
|
# images: |
|
|
|
|
# kanidm/kanidmd
|
|
|
|
# ghcr.io/username/app
|
|
|
|
# generate Docker tags based on the following events/attributes
|
|
|
|
tags: |
|
|
|
|
type=schedule
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=pr
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
type=semver,pattern={{major}}
|
|
|
|
type=sha
|
|
|
|
|
2023-07-18 01:03:04 +02:00
|
|
|
- name: Build kanidmd
|
2023-09-17 22:42:01 +02:00
|
|
|
uses: docker/build-push-action@v5
|
2022-06-20 12:16:55 +02:00
|
|
|
with:
|
2023-07-18 01:03:04 +02:00
|
|
|
platforms: "linux/amd64"
|
|
|
|
tags: ghcr.io/${{ github.repository_owner }}/kanidmd:devel
|
2022-09-08 08:40:58 +02:00
|
|
|
# build-args: |
|
2023-07-18 01:03:04 +02:00
|
|
|
# "KANIDM_BUILD_OPTIONS=-j1"
|
2023-03-02 03:47:23 +01:00
|
|
|
file: server/Dockerfile
|
2023-07-18 01:03:04 +02:00
|
|
|
# Must use OCI exporter for multi-arch: https://github.com/docker/buildx/pull/1813
|
|
|
|
outputs: type=oci,dest=/tmp/kanidmd-docker.tar
|
|
|
|
- name: Upload artifact
|
2023-12-18 01:56:02 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-07-18 01:03:04 +02:00
|
|
|
with:
|
|
|
|
name: kanidmd-docker
|
|
|
|
path: /tmp/kanidmd-docker.tar
|
|
|
|
|
|
|
|
kanidmd_push:
|
|
|
|
name: Push kanidmd 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 == 'refs/heads/master' && github.repository == 'kanidm/kanidm'
|
|
|
|
needs: kanidmd_build
|
|
|
|
permissions:
|
|
|
|
packages: write
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Download artifact
|
2023-12-18 01:56:02 +01:00
|
|
|
uses: actions/download-artifact@v4
|
2023-07-18 01:03:04 +02:00
|
|
|
with:
|
|
|
|
name: kanidmd-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/kanidmd-docker.tar:devel" "ghcr.io/${{ github.repository_owner }}/kanidmd:devel"
|