Publish Helm #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 Helm | |
on: | |
workflow_dispatch | |
env: | |
REGISTRY: ghcr.io | |
CHART_DIRECTORY: chart | |
RELEASE_TAG_PREFIX: helm | |
jobs: | |
create_release_tag: | |
name: Create release tag | |
runs-on: ubuntu-24.04 | |
outputs: | |
tag: ${{ steps.get_tag.outputs.tag }} | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: azure/setup-helm@v4 | |
- name: Determine target commit | |
id: get_target_commit | |
run: | | |
sha=$(git rev-parse HEAD) | |
echo "Target commit: $sha" | |
echo "sha=$sha" >> $GITHUB_OUTPUT | |
- name: Get tag | |
id: get_tag | |
run: | | |
chart_version=$(yq .version $CHART_DIRECTORY/Chart.yaml) | |
echo "tag=$RELEASE_TAG_PREFIX/$chart_version" >> $GITHUB_OUTPUT | |
- name: Wait for check suites to complete | |
uses: sap-contributions/await-check-suites@master | |
with: | |
ref: ${{ steps.get_target_commit.outputs.sha }} | |
intervalSeconds: 10 | |
timeoutSeconds: 1800 | |
failStepIfUnsuccessful: true | |
appSlugFilter: github-actions | |
- name: Create release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ steps.get_tag.outputs.tag }} | |
commit: ${{ steps.get_target_commit.outputs.sha }} | |
makeLatest: false | |
prerelease: false | |
allowUpdates: false | |
publish-to-pages: | |
name: Publish chart to github pages | |
runs-on: ubuntu-24.04 | |
needs: create_release_tag | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: website | |
path: website | |
token: ${{ secrets.WORKFLOW_USER_TOKEN }} | |
- uses: azure/setup-helm@v4 | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Create package | |
run: | | |
chart_version=$(yq .version $CHART_DIRECTORY/Chart.yaml) | |
helm package --version $chart_version $CHART_DIRECTORY | |
- name: Create index | |
run: | | |
helm repo index --url ${{ github.server_url }}/${{ github.repository }}/releases/download/${{ needs.create_release_tag.outputs.tag }} --merge ./website/static/index.yaml . | |
mv index.yaml website/static | |
cd website | |
git config user.name "${{ vars.WORKFLOW_USER_NAME }}" | |
git config user.email "${{ vars.WORKFLOW_USER_EMAIL }}" | |
git add . | |
git commit -m "Add index.yaml to website" | |
git push | |
- name: Upload package | |
run: | | |
upload_url="${{ needs.create_release_tag.outputs.upload_url }}" | |
upload_url=${upload_url%%\{*\}} | |
chart_name=$(yq .name $CHART_DIRECTORY/Chart.yaml) | |
chart_version=$(yq .version $CHART_DIRECTORY/Chart.yaml) | |
file=$chart_name-$chart_version.tgz | |
echo "Uploading $file to $upload_url ..." | |
curl -sSf \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ github.token }}" \ | |
-H "Content-Type: $(file -b --mime-type $file)" \ | |
--data-binary @$file \ | |
"$upload_url?name=$(basename $file)" | |
publish-to-packages: | |
name: Publish chart to github packages | |
needs: create_release_tag | |
runs-on: ubuntu-24.04 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: azure/setup-helm@v4 | |
- name: Create package | |
run: | | |
chart_version=$(yq .version $CHART_DIRECTORY/Chart.yaml) | |
helm package --version $chart_version $CHART_DIRECTORY | |
- name: Login to the OCI registry | |
run: | | |
helm --registry-config $RUNNER_TEMP/helm-config.json registry login $REGISTRY -u ${{ github.actor }} --password-stdin <<< ${{ github.token }} | |
- name: Upload package | |
run: | | |
chart_name=$(yq .name $CHART_DIRECTORY/Chart.yaml) | |
chart_version=$(yq .version $CHART_DIRECTORY/Chart.yaml) | |
file=$chart_name-$chart_version.tgz | |
repository=$REGISTRY/${{ github.repository }}/$RELEASE_TAG_PREFIX | |
helm --registry-config $RUNNER_TEMP/helm-config.json push $file oci://${repository,,} |