From a2270ac4b8aa39f5804ace14276f1d4e97f3716e Mon Sep 17 00:00:00 2001 From: dd di cesare Date: Thu, 20 Jun 2024 19:33:58 +0200 Subject: [PATCH] [refactor] Adjusting package creation sync workflow * Specific target for sync package created * Workflow ran on release and dispatch consuming the tag --- .github/workflows/release-helm-chart.yaml | 31 +++++++++++------------ make/helm.mk | 6 ++--- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release-helm-chart.yaml b/.github/workflows/release-helm-chart.yaml index 9d59143f..73aa5e40 100644 --- a/.github/workflows/release-helm-chart.yaml +++ b/.github/workflows/release-helm-chart.yaml @@ -3,21 +3,15 @@ name: Release Helm Chart on: -# TODO: The following commented lines should be used depending on the release strategy -# release: -# types: -# - released -# OR for a full release workflow -# push: -# tags: -# - 'v*.*.*' + release: + types: + - published workflow_dispatch: inputs: - operatorVersion: - description: Operator bundle version - default: 0.0.0 + operatorTag: + description: Operator bundle version tag + default: v0.0.0 type: string - jobs: chart_release: runs-on: ubuntu-latest @@ -40,19 +34,24 @@ jobs: run: | make helm-package + - name: Parse Tag + run: | + tag=${{ github.event.release.tag_name || inputs.operatorTag }} + echo "OPERATOR_VERSION=${tag#v}" >> $GITHUB_ENV + - name: Upload package to GitHub Release uses: svenstaro/upload-release-action@v2 id: upload-chart with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: limitador-operator-${{ inputs.operatorVersion }}.tgz - asset_name: chart-limitador-operator-${{ inputs.operatorVersion }}.tgz + file: limitador-operator-${{ env.OPERATOR_VERSION }}.tgz + asset_name: chart-limitador-operator-${{ env.OPERATOR_VERSION }}.tgz tag: ${{ github.ref }} overwrite: true - name: Sync Helm Chart with repository run: | - make helm-sync-package \ - VERSION=${{ inputs.operatorVersion }} \ + make helm-sync-package-created \ + VERSION=${{env.OPERATOR_VERSION}} \ HELM_WORKFLOWS_TOKEN=${{ secrets.HELM_WORKFLOWS_TOKEN }} \ BROWSER_DOWNLOAD_URL=${{ steps.upload-chart.outputs.browser_download_url }} diff --git a/make/helm.mk b/make/helm.mk index b780b40d..0568a3af 100644 --- a/make/helm.mk +++ b/make/helm.mk @@ -42,12 +42,12 @@ else CHART_VERSION = $(VERSION) endif -.PHONY: helm-sync-package -helm-sync-package: $(HELM) ## Sync the helm chart package to the helm-charts repo +.PHONY: helm-sync-package-created +helm-sync-package-created: $(HELM) ## Sync the helm chart package to the helm-charts repo curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer $(HELM_WORKFLOWS_TOKEN)" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/$(ORG)/$(HELM_REPO_NAME)/dispatches \ - -d '{"event_type":"sync-chart","client_payload":{"chart":"$(REPO_NAME)","version":"$(CHART_VERSION)", "browser_download_url": "$(BROWSER_DOWNLOAD_URL)"}}' + -d '{"event_type":"chart-created","client_payload":{"chart":"$(REPO_NAME)","version":"$(CHART_VERSION)", "browser_download_url": "$(BROWSER_DOWNLOAD_URL)"}}'