Publish OperatorHub release #43
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: Publish OperatorHub release | |
on: | |
workflow_dispatch: | |
ref: master | |
branches: | |
- master | |
permissions: | |
teams: | |
- development | |
workflow_run: | |
workflows: | |
- Release | |
types: | |
- completed | |
jobs: | |
update: | |
name: Publish new OperatorHub release | |
runs-on: ubuntu-latest | |
if: ${{ (github.event.workflow_run.conclusion == 'success' && ! contains(github.event.workflow_run.head_branch, '-')) || github.event_name == 'workflow_dispatch' }} | |
strategy: | |
matrix: | |
repo: | |
- fork: VictoriaMetrics/operatorhub-operators | |
upstream: k8s-operatorhub/community-operators | |
- fork: VictoriaMetrics/openshift-community-operators-prod | |
upstream: redhat-openshift-ecosystem/community-operators-prod | |
steps: | |
- name: Sync forks | |
run: | | |
gh repo sync ${{ matrix.repo.fork }} | |
env: | |
GH_TOKEN: ${{ secrets.VM_BOT_GH_TOKEN }} | |
- name: Check out OperatorHub operators repo fork | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ matrix.repo.upstream }} | |
ref: main | |
token: ${{ secrets.VM_BOT_GH_TOKEN }} | |
path: __k8s-operatorhub-repo | |
- name: Import GPG key | |
uses: crazy-max/ghaction-import-gpg@v6 | |
id: import-gpg | |
with: | |
gpg_private_key: ${{ secrets.VM_BOT_GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.VM_BOT_PASSPHRASE }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
workdir: __k8s-operatorhub-repo | |
- uses: dawidd6/action-download-artifact@v6 | |
if: ${{ github.event_name == 'workflow_run' }} | |
with: | |
name: olm | |
workflow: main.yaml | |
github_token: ${{ secrets.VM_BOT_GH_TOKEN }} | |
run_id: ${{ github.event.workflow_run.id }} | |
path: bundle | |
- name: Add operatorhub bundle | |
id: update | |
run: | | |
mkdir -p __k8s-operatorhub-repo/catalogs | |
OPERATOR_DIR=__k8s-operatorhub-repo/operators/victoriametrics-operator | |
mkdir -p ${OPERATOR_DIR} | |
export PREV_VERSION=$(find ${OPERATOR_DIR}/* ! -path "*/catalog-templates" -maxdepth 0 -type d -exec basename {} \; | sort -V -r | head -2 | tail -1) | |
export LATEST_VERSION=$(find ${OPERATOR_DIR}/* ! -path "*/catalog-templates" -maxdepth 0 -type d -exec basename {} \; | sort -V -r | head -1) | |
if [ -d bundle ]; then | |
export VERSION=$(ls bundle | head -1) | |
export MANIFEST_PATH=bundle/${VERSION}/manifests/victoriametrics-operator.clusterserviceversion.yaml | |
yq -i '.spec.replaces = "victoriametrics-operator.v" + strenv(LATEST_VERSION)' $MANIFEST_PATH | |
mv bundle/* ${OPERATOR_DIR}/ | |
if [ -f ${OPERATOR_DIR}/Makefile ]; then | |
yq -i '.fbc.enabled = true' ${OPERATOR_DIR}/ci.yaml | |
else | |
yq -i '.updateGraph = "replaces-mode"' ${OPERATOR_DIR}/ci.yaml | |
fi | |
elif [ -f ${OPERATOR_DIR}/Makefile ]; then | |
cd ${OPERATOR_DIR} | |
export NEW_ENTRY="victoriametrics-operator.v${LATEST_VERSION}" | |
export OLD_ENTRY="victoriametrics-operator.v${PREV_VERSION}" | |
export BUNDLE_IMAGE="quay.io/community-operator-pipeline-prod/victoriametrics-operator:${LATEST_VERSION}" | |
find catalog-templates \ | |
-path "*.yaml" \ | |
-exec yq -i -I2 '.entries |= .[] |= select(. | has("entries")).entries += [{"name": strenv(NEW_ENTRY), "replaces": strenv(OLD_ENTRY)}]' {} \; | |
find catalog-templates \ | |
-path "*.yaml" \ | |
-exec yq -i -I2 '.entries |= . += [{"image": strenv(BUNDLE_IMAGE), "schema": "olm.bundle"}]' {} \; | |
make catalogs | |
export VERSION=${LATEST_VERSION} | |
fi | |
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
- name: Create Pull Request | |
if: ${{ steps.update.outputs.VERSION != '' }} | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
add-paths: operators/victoriametrics-operator,catalogs | |
commit-message: 'victoriametrics-operator: ${{ steps.update.outputs.VERSION }}' | |
signoff: true | |
committer: "Github Actions <${{ steps.import-gpg.outputs.email }}>" | |
path: __k8s-operatorhub-repo | |
push-to-fork: ${{ matrix.repo.fork }} | |
branch: vm-operator-release-${{ steps.update.outputs.VERSION }} | |
token: ${{ secrets.VM_BOT_GH_TOKEN }} | |
delete-branch: true | |
title: 'victoriametrics-operator: (${{ steps.update.outputs.VERSION }})' | |
body: | | |
Added OLM package for [VictoriaMetrics operator ${{ steps.update.outputs.VERSION }}"](/~https://github.com/VictoriaMetrics/operator/releases/tag/v${{ steps.update.outputs.VERSION }}) | |
> Auto-generated by `Github Actions Bot` |