Skip to content

Commit

Permalink
[refactor] Using svenstaro/upload-release-action@v2
Browse files Browse the repository at this point in the history
* Instead of curl to endpoint
* Removing makefile target previously used
* Not passing asset_id to sync package target
  • Loading branch information
didierofrivia committed Jun 18, 2024
1 parent 25f5aed commit 4b9937f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/release-helm-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,18 @@ jobs:
make helm-package
- name: Upload package to GitHub Release
run: |
response = make helm-upload-package \
VERSION=${{ inputs.operatorVersion }} \
GITHUB_TOKEN=${{ secrets.HELM_WORKFLOWS_TOKEN }} \
RELEASE_ID=${{ inputs.releaseId }}
echo "response: $response" >> $GITHUB_ENV
uses: svenstaro/upload-release-action@v2
id: upload-chart
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: charts/limitador-operator-${{ inputs.operatorVersion }}.tgz
asset_name: chart-limitador-operator-${{ inputs.operatorVersion }}.tgz
tag: ${{ github.ref }}
overwrite: true

- name: Sync Helm Chart with repository
run: |
make helm-sync-package \
VERSION=${{ inputs.operatorVersion }} \
GITHUB_TOKEN=${{ secrets.HELM_WORKFLOWS_TOKEN }} \
ASSET_ID=${{ env.response.id }}
BROWSER_DOWNLOAD_URL=${{ env.response.browser_download_url }}
BROWSER_DOWNLOAD_URL=${{ steps.upload-chart.outputs.browser_download_url }}
17 changes: 1 addition & 16 deletions make/helm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ helm-package: $(HELM) ## Package the helm chart

# GitHub Token with permissions to upload to the release assets
GITHUB_TOKEN ?= <YOUR-TOKEN>
# GitHub Release ID, to find the release_id query the GET /repos/{owner}/{repo}/releases/latest or GET /repos/{owner}/{repo}/releases endpoints
RELEASE_ID ?= <RELEASE-ID>
# GitHub Release Asset ID, it can be find in the output of the uploaded asset
ASSET_ID ?= <ASSET-ID>
# GitHub Release Asset Browser Download URL, it can be find in the output of the uploaded asset
BROWSER_DOWNLOAD_URL ?= <BROWSER-DOWNLOAD-URL>
# Github repo name for the helm charts repository
Expand All @@ -46,17 +42,6 @@ else
CHART_VERSION = $(VERSION)
endif

.PHONY: helm-upload-package
helm-upload-package: $(HELM) ## Upload the helm chart package to the GitHub release assets
curl -L -s \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $(GITHUB_TOKEN)" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/$(ORG)/$(REPO_NAME)/releases/$(RELEASE_ID)/assets?name=chart-limitador-operator-$(CHART_VERSION).tgz" \
--data-binary "@limitador-operator-$(CHART_VERSION).tgz"

.PHONY: helm-sync-package
helm-sync-package: $(HELM) ## Sync the helm chart package to the helm-charts repo
curl -L \
Expand All @@ -65,4 +50,4 @@ helm-sync-package: $(HELM) ## Sync the helm chart package to the helm-charts rep
-H "Authorization: Bearer $(GITHUB_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)", "asset_id":"$(ASSET_ID)", "browser_download_url": "$(BROWSER_DOWNLOAD_URL)"}}'
-d '{"event_type":"sync-chart","client_payload":{"chart":"$(REPO_NAME)","version":"$(CHART_VERSION)", "browser_download_url": "$(BROWSER_DOWNLOAD_URL)"}}'

0 comments on commit 4b9937f

Please sign in to comment.