constellation/.github/actions/build_operator/action.yml

109 lines
3.8 KiB
YAML
Raw Normal View History

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-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
uses: docker/login-action@dd4fa0671be5250ee6f50aedf4cb05514abda2c7
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ inputs.githubToken }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@b2391d37b4157fa4aa2e118d643f417910ff3242
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
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: ${{ inputs.sourceDir }}
file: ${{ inputs.sourceDir }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
- name: Bundle for pseudo version
if: ${{ steps.pseudo-version.outputs.pseudoVersion != '' && inputs.pushTag == '' }}
shell: bash
run: make bundle VERSION=${VERSION#v}
working-directory: ${{ inputs.sourceDir }}
env:
VERSION: ${{ steps.pseudo-version.outputs.pseudoVersion }}
- name: Bundle for semantic version
if: ${{ inputs.pushTag != '' }}
shell: bash
run: make bundle VERSION=${VERSION#v}
working-directory: ${{ inputs.sourceDir }}
env:
VERSION: ${{ inputs.pushTag }}
- name: Docker metadata for bundle
id: bundle-meta
uses: docker/metadata-action@b2391d37b4157fa4aa2e118d643f417910ff3242
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
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: ${{ inputs.sourceDir }}
file: ${{ inputs.sourceDir }}/bundle.Dockerfile
push: true
tags: ${{ steps.bundle-meta.outputs.tags }}
- name: Build and push catalog for pseudo versions
if: ${{ steps.pseudo-version.outputs.pseudoVersion != '' && inputs.pushTag == '' }}
shell: bash
run: make VERSION=${VERSION#v} catalog-build catalog-push
working-directory: ${{ inputs.sourceDir }}
env:
VERSION: ${{ steps.pseudo-version.outputs.pseudoVersion }}
- name: Build and push catalog for releases
if: ${{ inputs.pushTag != '' }}
shell: bash
run: make VERSION=${VERSION#v} catalog-build catalog-push
working-directory: ${{ inputs.sourceDir }}
env:
VERSION: ${{ inputs.pushTag }}