check-helm #259
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: check-helm | |
on: | |
schedule: | |
- cron: "0 4 * * *" | |
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/main/resources/tools.json | jq -r .tools.helm.version)" >> $GITHUB_ENV | |
baseUrl="https://mirror.openshift.com/pub/openshift-v4/clients/helm" | |
echo "LATEST_TOOL_URL=$(echo ${baseUrl})" >> $GITHUB_ENV | |
echo "LATEST_TOOL_RELEASE=$(curl -s -L ${baseUrl} | grep "${baseUrl}" | sed "s|${baseUrl}||" | grep -v "latest" | sed 's/[^"]*"\([^"]*\).*/\1/' | sed "s|/||g" | sort -V | tail -n 1)" >> $GITHUB_ENV | |
- name: Find existing PR for HELM version | |
run: | | |
echo PR_EXISTS=$(gh pr --repo ${{ github.repository }} list --state open --search "fix: update helm ${{env.LATEST_TOOL_RELEASE}} in:title" --json url | jq length) >> $GITHUB_ENV | |
- name: Update tools.json with latest helm version | |
if: ${{ (env.LATEST_TOOL_RELEASE != '') && (env.LATEST_TOOL_RELEASE != env.REPO_HELM_VERSION) && (env.PR_EXISTS == 0) }} | |
run: | | |
jq --indent 4 '.tools.helm.version = "${{ env.LATEST_TOOL_RELEASE }}"' src/main/resources/tools.json | jq --indent 4 '.tools.helm.versionMatchRegExpr = "${{ env.LATEST_TOOL_RELEASE }}"' > src/main/resources/tools.json.new | |
mv src/main/resources/tools.json.new src/main/resources/tools.json | |
for platform in win osx \"osx-aarch64\" lnx ; do | |
old_url=`jq -r .tools.helm.platforms.${platform}.url src/main/resources/tools.json` | |
new_url=`echo ${old_url} | sed "s|${{ env.REPO_HELM_VERSION }}|${{ env.LATEST_TOOL_RELEASE }}|"` | |
checksum_url=`echo "${new_url}.sha256"` | |
checksum=`curl -s -L ${checksum_url} | sed "s| ||g"` | |
jq --indent 4 ".tools.helm.platforms.${platform}.url = \"${new_url}\"" src/main/resources/tools.json \ | |
| jq --indent 4 ".tools.helm.platforms.${platform}.sha256sum = \"${checksum}\"" > src/main/resources/tools.json.new | |
mv src/main/resources/tools.json.new src/main/resources/tools.json | |
done | |
- name: Create pull request | |
if: ${{ (env.LATEST_TOOL_RELEASE != '') && (env.LATEST_TOOL_RELEASE != env.REPO_HELM_VERSION) && (env.PR_EXISTS == 0) }} | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Action" | |
git checkout -b "helm-${{ env.LATEST_TOOL_RELEASE }}" | |
git commit -am "fix: Update helm to ${{ env.LATEST_TOOL_RELEASE }}" | |
git push origin "helm-${{ env.LATEST_TOOL_RELEASE }}" | |
gh pr create --title "fix: Update helm to ${{ env.LATEST_TOOL_RELEASE }}" --body "See ${{ env.LATEST_TOOL_URL }}" |