push-manifests #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: push-manifests | |
on: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
env: | |
CONTROLLER: ${{ github.event.repository.name }} | |
jobs: | |
flux-push: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write # for creating OIDC tokens for signing. | |
packages: write # for pushing and signing container images. | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Setup Kustomize | |
uses: fluxcd/pkg/actions/kustomize@main | |
- name: Setup Flux | |
uses: fluxcd/flux2/action@896e0fa46d5107a05e953dd0a5261d78a145ec8c #v2.3.0 | |
- name: Prepare | |
id: prep | |
run: | | |
RELEASE=$(gh release view --json tagName -q '.tagName') | |
VERSION="${RELEASE}-$(date +%s)" | |
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.0 | |
- name: Push and sign manifests | |
env: | |
COSIGN_EXPERIMENTAL: 1 | |
run: | | |
set -euo pipefail | |
make build-manifests | |
img_digest=$(flux push artifact \ | |
oci://ghcr.io/controlplaneio-fluxcd/${{ env.CONTROLLER }}-manifests:${{ steps.prep.outputs.VERSION }} \ | |
--path=disto \ | |
--source=${{ github.repositoryUrl }} \ | |
--revision="${{ github.ref_name }}@sha1:${{ github.sha }}" \ | |
--annotations='org.opencontainers.image.description=Flux Operator' \ | |
--output=json | jq -r '.digest') | |
cosign sign --yes ghcr.io/controlplaneio-fluxcd/${{ env.CONTROLLER }}-manifests@${img_digest} | |
flux tag artifact oci://ghcr.io/controlplaneio-fluxcd/${{ env.CONTROLLER }}-manifests:${{ steps.prep.outputs.VERSION }} --tag=latest |