2022-08-08 09:50:37 -04:00
|
|
|
name: Build operator
|
|
|
|
description: Build and upload a container image for a Constellation operator
|
|
|
|
inputs:
|
|
|
|
name:
|
2022-09-14 09:14:26 -04:00
|
|
|
description: "Name of the operator"
|
2022-08-08 09:50:37 -04:00
|
|
|
required: true
|
|
|
|
sourceDir:
|
2022-09-14 09:14:26 -04:00
|
|
|
description: "Path to the operators source directory"
|
2022-08-08 09:50:37 -04:00
|
|
|
required: true
|
|
|
|
pushTag:
|
2022-09-14 09:14:26 -04:00
|
|
|
description: "Use this image tag"
|
2022-08-08 09:50:37 -04:00
|
|
|
required: false
|
|
|
|
githubToken:
|
2022-09-14 09:14:26 -04:00
|
|
|
description: "GitHub authorization token"
|
2022-08-08 09:50:37 -04:00
|
|
|
required: true
|
2022-10-21 09:19:51 -04:00
|
|
|
cosignPublicKey:
|
|
|
|
description: "Cosign public key"
|
|
|
|
required: false
|
|
|
|
cosignPrivateKey:
|
|
|
|
description: "Cosign private key"
|
|
|
|
required: false
|
|
|
|
cosignPassword:
|
|
|
|
description: "Password for Cosign private key"
|
|
|
|
required: false
|
2022-08-08 09:50:37 -04:00
|
|
|
|
2022-09-14 09:14:26 -04:00
|
|
|
# Linux runner only (Docker required)
|
2022-08-08 09:50:37 -04:00
|
|
|
runs:
|
|
|
|
using: "composite"
|
|
|
|
steps:
|
|
|
|
- name: Determine pseudo version
|
|
|
|
id: pseudo-version
|
|
|
|
uses: ./.github/actions/pseudo_version
|
|
|
|
|
|
|
|
- name: Install operator-sdk
|
|
|
|
uses: ./.github/actions/install_operator_sdk
|
|
|
|
with:
|
|
|
|
version: v1.22.2
|
|
|
|
|
|
|
|
- name: Log in to the Container registry
|
|
|
|
id: docker-login
|
2022-10-12 12:05:58 -04:00
|
|
|
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # tag=v2.1.0
|
2022-08-08 09:50:37 -04:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ inputs.githubToken }}
|
|
|
|
|
|
|
|
- name: Docker metadata
|
|
|
|
id: meta
|
2023-01-18 11:04:46 -05:00
|
|
|
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0
|
2022-08-08 09:50:37 -04:00
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
ghcr.io/${{ github.repository }}/${{ inputs.name }}
|
|
|
|
tags: |
|
|
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
type=raw,value=${{ inputs.pushTag }},enable=${{ '' != inputs.pushTag }}
|
|
|
|
type=raw,value=${{ steps.pseudo-version.outputs.pseudoVersion }},enable=${{ '' != steps.pseudo-version.outputs.pseudoVersion }}
|
|
|
|
type=ref,event=branch
|
|
|
|
|
|
|
|
- name: Build and push container image
|
2022-10-21 09:19:51 -04:00
|
|
|
id: build-image
|
2023-01-31 11:38:44 -05:00
|
|
|
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1
|
2022-08-08 09:50:37 -04:00
|
|
|
with:
|
2023-01-04 13:04:28 -05:00
|
|
|
context: .
|
2022-08-08 09:50:37 -04:00
|
|
|
file: ${{ inputs.sourceDir }}/Dockerfile
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
|
2022-10-21 09:19:51 -04:00
|
|
|
- name: Generate SBOM
|
2023-01-18 04:15:58 -05:00
|
|
|
if: inputs.cosignPublicKey != '' && inputs.cosignPrivateKey != '' && inputs.cosignPassword != ''
|
2022-10-21 09:19:51 -04:00
|
|
|
uses: ./.github/actions/container_sbom
|
|
|
|
with:
|
|
|
|
containerReference: ghcr.io/${{ github.repository }}/${{ inputs.name }}@${{ steps.build-image.outputs.digest }}
|
|
|
|
cosignPublicKey: ${{ inputs.cosignPublicKey }}
|
|
|
|
cosignPrivateKey: ${{ inputs.cosignPrivateKey }}
|
|
|
|
cosignPassword: ${{ inputs.cosignPassword }}
|
|
|
|
|
2022-08-08 09:50:37 -04:00
|
|
|
- name: Bundle for pseudo version
|
2023-01-17 12:49:00 -05:00
|
|
|
if: steps.pseudo-version.outputs.pseudoVersion != '' && inputs.pushTag == ''
|
2022-08-08 09:50:37 -04:00
|
|
|
shell: bash
|
|
|
|
working-directory: ${{ inputs.sourceDir }}
|
|
|
|
env:
|
|
|
|
VERSION: ${{ steps.pseudo-version.outputs.pseudoVersion }}
|
2023-01-18 04:15:58 -05:00
|
|
|
run: make bundle VERSION=${VERSION#v}
|
2022-08-08 09:50:37 -04:00
|
|
|
|
|
|
|
- name: Bundle for semantic version
|
2023-01-17 12:49:00 -05:00
|
|
|
if: inputs.pushTag != ''
|
2022-08-08 09:50:37 -04:00
|
|
|
shell: bash
|
|
|
|
working-directory: ${{ inputs.sourceDir }}
|
|
|
|
env:
|
|
|
|
VERSION: ${{ inputs.pushTag }}
|
2023-01-18 04:15:58 -05:00
|
|
|
run: make bundle VERSION=${VERSION#v}
|
2022-08-08 09:50:37 -04:00
|
|
|
|
|
|
|
- name: Docker metadata for bundle
|
|
|
|
id: bundle-meta
|
2023-01-18 11:04:46 -05:00
|
|
|
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0
|
2022-08-08 09:50:37 -04:00
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
ghcr.io/${{ github.repository }}/${{ inputs.name }}-bundle
|
|
|
|
tags: |
|
|
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
type=raw,value=${{ inputs.pushTag }},enable=${{ '' != inputs.pushTag }}
|
|
|
|
type=raw,value=${{ steps.pseudo-version.outputs.pseudoVersion }},enable=${{ '' != steps.pseudo-version.outputs.pseudoVersion }}
|
|
|
|
type=ref,event=branch
|
|
|
|
|
|
|
|
- name: Build and push bundle image
|
2022-10-21 09:19:51 -04:00
|
|
|
id: build-image-bundle
|
2023-01-31 11:38:44 -05:00
|
|
|
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1
|
2022-08-08 09:50:37 -04:00
|
|
|
with:
|
|
|
|
context: ${{ inputs.sourceDir }}
|
|
|
|
file: ${{ inputs.sourceDir }}/bundle.Dockerfile
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.bundle-meta.outputs.tags }}
|
|
|
|
|
2022-10-21 09:19:51 -04:00
|
|
|
- name: Generate Bundle SBOM
|
2023-01-18 04:15:58 -05:00
|
|
|
if: inputs.cosignPublicKey != '' && inputs.cosignPrivateKey != '' && inputs.cosignPassword != ''
|
2022-10-21 09:19:51 -04:00
|
|
|
uses: ./.github/actions/container_sbom
|
|
|
|
with:
|
|
|
|
containerReference: ghcr.io/${{ github.repository }}/${{ inputs.name }}-bundle@${{ steps.build-image-bundle.outputs.digest }}
|
|
|
|
cosignPublicKey: ${{ inputs.cosignPublicKey }}
|
|
|
|
cosignPrivateKey: ${{ inputs.cosignPrivateKey }}
|
|
|
|
cosignPassword: ${{ inputs.cosignPassword }}
|
|
|
|
|
2022-08-08 09:50:37 -04:00
|
|
|
- name: Build and push catalog for pseudo versions
|
2023-01-17 12:49:00 -05:00
|
|
|
if: steps.pseudo-version.outputs.pseudoVersion != '' && inputs.pushTag == ''
|
2022-08-08 09:50:37 -04:00
|
|
|
shell: bash
|
|
|
|
working-directory: ${{ inputs.sourceDir }}
|
|
|
|
env:
|
|
|
|
VERSION: ${{ steps.pseudo-version.outputs.pseudoVersion }}
|
2023-01-18 04:15:58 -05:00
|
|
|
run: make VERSION=${VERSION#v} catalog-build catalog-push
|
2022-08-08 09:50:37 -04:00
|
|
|
|
|
|
|
- name: Build and push catalog for releases
|
2023-01-17 12:49:00 -05:00
|
|
|
if: inputs.pushTag != ''
|
2022-08-08 09:50:37 -04:00
|
|
|
shell: bash
|
|
|
|
working-directory: ${{ inputs.sourceDir }}
|
|
|
|
env:
|
|
|
|
VERSION: ${{ inputs.pushTag }}
|
2023-01-18 04:15:58 -05:00
|
|
|
run: make VERSION=${VERSION#v} catalog-build catalog-push
|