Publish OperatorHub release #47
This file contains hidden or 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_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 | |
| 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: | | |
| if [ ! -d bundle ]; then | |
| echo "No bundle directory found" | |
| exit 1; | |
| fi | |
| OPERATOR_DIR=__k8s-operatorhub-repo/operators/victoriametrics-operator | |
| CATALOGS_DIR=__k8s-operatorhub-repo/catalogs | |
| mkdir -p ${CATALOGS_DIR} | |
| mkdir -p ${OPERATOR_DIR} | |
| export OLD_VERSION=$(find ${OPERATOR_DIR}/* ! -path "*/catalog-templates" -maxdepth 0 -type d -exec basename {} \; | sort -V -r | head -1) | |
| export OLD_ENTRY="victoriametrics-operator.v${OLD_VERSION}" | |
| export NEW_VERSION=$(ls bundle | head -1) | |
| export NEW_ENTRY="victoriametrics-operator.v${NEW_VERSION}" | |
| export MANIFEST_PATH=bundle/${NEW_VERSION}/manifests/victoriametrics-operator.clusterserviceversion.yaml | |
| export BUNDLE_IMAGE="quay.io/community-operator-pipeline-prod/victoriametrics-operator:${NEW_VERSION}" | |
| if [ ! -z $OLD_VERSION ]; then | |
| yq -i '.spec.replaces = "victoriametrics-operator.v" + strenv(OLD_VERSION)' $MANIFEST_PATH | |
| fi | |
| mv bundle/* ${OPERATOR_DIR}/ | |
| if [ -f ${OPERATOR_DIR}/Makefile ]; then | |
| yq -i 'del(.updateGraph)' ${OPERATOR_DIR}/ci.yaml | |
| cd ${OPERATOR_DIR} | |
| 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 | |
| else | |
| yq -i 'del(.fbc)' ${OPERATOR_DIR}/ci.yaml | |
| fi | |
| echo "VERSION=$NEW_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` |