Skip to content

check-helm

check-helm #359

Workflow file for this run

name: check-helm
on:
schedule:
- cron: "0 8 * * *"
workflow_dispatch:
jobs:
check-helm-repo:
runs-on: ubuntu-latest
env:
TOOL_REPO: helm/helm
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check Out Code
uses: actions/checkout@v4
- name: Get latest HELM version
run: |
echo "REPO_HELM_VERSION=$(cat src/tools.json | jq -r .helm.version)" >> $GITHUB_ENV
LATEST_TOOL_RELEASE_RESP=$(gh release --repo ${{ env.TOOL_REPO }} view --json tagName,url)
echo "LATEST_TOOL_RELEASE=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .tagName)" >> $GITHUB_ENV
echo "LATEST_TOOL_VERSION=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .tagName | sed 's|v||')" >> $GITHUB_ENV
echo "LATEST_TOOL_URL=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .url)" >> $GITHUB_ENV
- name: Find existing PR for HELM version
if: ${{ env.LATEST_TOOL_VERSION != '' }}
run: |
if [[ "${{ env.LATEST_TOOL_VERSION != env.REPO_HELM_VERSION }}" == "true" ]]; then
prFound=$(gh pr --repo ${{ github.repository }} list --state all --search "update helm cli to ${{env.LATEST_TOOL_RELEASE}} in:title" --json url | jq length)
if [[ $prFound == 0 ]]; then
echo SHOULD_UPDATE=true >> $GITHUB_ENV
fi
fi
- name: Update src/tools.json with latest helm version
if: ${{ env.SHOULD_UPDATE == 'true' }}
run: |
jq --indent 4 '.helm.description = "Helm CLI tool"' src/tools.json \
| jq --indent 4 '.helm.vendor = "The Helm Project"' \
| jq --indent 4 '.helm.version = "${{ env.LATEST_TOOL_VERSION }}"' \
| jq --indent 4 '.helm.versionRange = "^${{ env.LATEST_TOOL_VERSION }}"' \
| jq --indent 4 '.helm.versionRangeLabel = "version >= ${{ env.LATEST_TOOL_VERSION }}"' > src/tools.json.new
mv src/tools.json.new src/tools.json
for platform in win32 darwin darwin-arm64 linux linux-arm64; do
pltfrm="$platform"
ext=".tar.gz"
exeExt=""
if [[ "$platform" == "win"* ]]; then
pltfrm="windows"
ext=".zip"
exeExt=".exe"
fi
arch="-amd64"
if [[ $platform == *"-a"* ]]; then
arch="" # already in platform string
fi
new_url="https://get.helm.sh/helm-${{ env.LATEST_TOOL_RELEASE }}-${pltfrm}${arch}${ext}"
checksum=`curl -s ${new_url}.sha256sum | sed -e 's/\s.*$//'`
dlFileName="helm-${pltfrm}${arch}${ext}"
filePrefix="${pltfrm}${arch}/"
cmdFileName="helm${exeExt}"
jq --indent 4 ".helm.platform[\"${platform}\"].url = \"${new_url}\"" src/tools.json \
| jq --indent 4 ".helm.platform[\"${platform}\"].sha256sum = \"${checksum}\"" \
| jq --indent 4 ".helm.platform[\"${platform}\"].dlFileName = \"${dlFileName}\"" \
| jq --indent 4 ".helm.platform[\"${platform}\"].filePrefix = \"${filePrefix}\"" \
| jq --indent 4 ".helm.platform[\"${platform}\"].cmdFileName = \"${cmdFileName}\"" > src/tools.json.new > src/tools.json.new
mv src/tools.json.new src/tools.json
done
- name: Create pull request
if: ${{ env.SHOULD_UPDATE == 'true' }}
run: |
git config --global user.email "openshifttools-bot@users.noreply.github.com"
git config --global user.name "openshifttools-bot"
git checkout -b "bump-helm-${{ env.LATEST_TOOL_RELEASE }}"
git commit -am "Update HELM CLI to ${{ env.LATEST_TOOL_RELEASE }}"
git push origin "bump-helm-${{ env.LATEST_TOOL_RELEASE }}"
gh pr create --title "Update HELM CLI to ${{ env.LATEST_TOOL_RELEASE }}" --body "See ${{ env.LATEST_TOOL_URL }}"