Skip to content

Publish artifacts (CRD yaml) on Release #1

Publish artifacts (CRD yaml) on Release

Publish artifacts (CRD yaml) on Release #1

Workflow file for this run

name: Publish artifacts
on:
release:
types: [published]
concurrency: release-${{ github.event.release.tag_name }}
env:
REGCTL_VERSION: v0.4.8
REGISTRY: ghcr.io
defaults:
run:
shell: bash
jobs:
publish-docker:
name: Publish Docker image
strategy:
matrix:
workload: ["controller", "server", "web-hooks", "mtx-job"]
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Prepare repository name
id: prepare-repository-name
run: |
repository=$REGISTRY/${{ github.repository }}/${{ matrix.workload }}
echo "repository=${repository,,}" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: extract-metadata
uses: docker/metadata-action@v4
with:
images: ${{ steps.prepare-repository-name.outputs.repository }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
file: build/${{ matrix.workload }}/Dockerfile
platforms: linux/amd64,linux/arm64
context: .
cache-from: |
type=gha,scope=sha-${{ github.sha }}
type=gha,scope=${{ github.ref_name }}-${{ matrix.workload }}
type=gha,scope=${{ github.base_ref || 'main' }}
type=gha,scope=main
cache-to: |
type=gha,scope=sha-${{ github.sha }},mode=max
type=gha,scope=${{ github.ref_name }}-${{ matrix.workload }},mode=max
push: true
tags: ${{ steps.extract-metadata.outputs.tags }}
labels: ${{ steps.extract-metadata.outputs.labels }}
publish-crds:
name: Publish CRD image
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup regctl
uses: regclient/actions/regctl-installer@main
with:
release: ${{ env.REGCTL_VERSION }}
install-dir: ${{ runner.temp }}/bin
- name: Log in to the registry
# regctl-login action is currently broken ...
# uses: regclient/actions/regctl-login@main
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ github.token }}
run: |
regctl registry login $REGISTRY --user ${{ github.actor }} --pass-stdin <<< ${{ github.token }}
- name: Build and push artifact
run: |
cd crds
repository=$REGISTRY/${{ github.repository }}/crds
tar cvz * | regctl artifact put -m application/gzip ${repository,,}:${{ github.event.release.tag_name }}