Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit 50c2797

Browse files
authored
chore: add helm cli workflow check (#729)
sonarlint fix Signed-off-by: Stephane Bouchet <[email protected]>
1 parent 4972284 commit 50c2797

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

.github/workflows/check-helm.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: check-helm
2+
3+
on:
4+
schedule:
5+
- cron: "0 4 * * *"
6+
workflow_dispatch:
7+
jobs:
8+
check-helm-repo:
9+
runs-on: ubuntu-latest
10+
env:
11+
TOOL_REPO: helm/helm
12+
GH_TOKEN: ${{ secrets.HELM_CHECK_TOKEN }}
13+
steps:
14+
- name: Check Out Code
15+
uses: actions/checkout@v4
16+
- name: Get latest HELM version
17+
run: |
18+
echo "REPO_HELM_VERSION=$(cat src/main/resources/tools.json | jq -r .tools.helm.version)" >> $GITHUB_ENV
19+
baseUrl="https://mirror.openshift.com/pub/openshift-v4/clients/helm"
20+
echo "LATEST_TOOL_URL=$(echo ${baseUrl})" >> $GITHUB_ENV
21+
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
22+
- name: Find existing PR for HELM version
23+
run: |
24+
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
25+
- name: Update tools.json with latest helm version
26+
if: ${{ (env.LATEST_TOOL_RELEASE != env.REPO_HELM_VERSION) && (env.PR_EXISTS == 0) }}
27+
run: |
28+
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
29+
mv src/main/resources/tools.json.new src/main/resources/tools.json
30+
for platform in win osx \"osx-aarch64\" lnx ; do
31+
old_url=`jq -r .tools.helm.platforms.${platform}.url src/main/resources/tools.json`
32+
new_url=`echo ${old_url} | sed "s|${{ env.REPO_HELM_VERSION }}|${{ env.LATEST_TOOL_RELEASE }}|"`
33+
checksum_url=`echo "${new_url}.sha256"`
34+
checksum=`curl -s -L ${checksum_url} | sed "s| ||g"`
35+
jq --indent 4 ".tools.helm.platforms.${platform}.url = \"${new_url}\"" src/main/resources/tools.json \
36+
| jq --indent 4 ".tools.helm.platforms.${platform}..sha256sum = \"${checksum}\"" > src/main/resources/tools.json.new
37+
mv src/main/resources/tools.json.new src/main/resources/tools.json
38+
done
39+
- name: Create pull request
40+
if: ${{ (env.LATEST_TOOL_RELEASE != env.REPO_HELM_VERSION) && (env.PR_EXISTS == 0) }}
41+
run: |
42+
git config --global user.email "[email protected]"
43+
git config --global user.name "openshifttools-bot"
44+
git checkout -b "helm-${{ env.LATEST_TOOL_RELEASE }}"
45+
git commit -am "fix: Update helm to ${{ env.LATEST_TOOL_RELEASE }}"
46+
git push origin "helm-${{ env.LATEST_TOOL_RELEASE }}"
47+
gh pr create --title "fix: Update helm to ${{ env.LATEST_TOOL_RELEASE }}" --body "See ${{ env.LATEST_TOOL_URL }}"

.github/workflows/check-odo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: |
2828
jq --indent 4 '.tools.odo.version = "${{ env.LATEST_TOOL_RELEASE }}"' src/main/resources/tools.json | jq --indent 4 '.tools.odo.versionMatchRegExpr = "${{ env.LATEST_TOOL_RELEASE }}"' > src/main/resources/tools.json.new
2929
mv src/main/resources/tools.json.new src/main/resources/tools.json
30-
for platform in win osx \"osx-arm64\" lnx \"lnx-arm64\"; do
30+
for platform in win osx \"osx-aarch64\" lnx \"lnx-arm64\"; do
3131
old_url=`jq -r .tools.odo.platforms.${platform}.url src/main/resources/tools.json`
3232
new_url=`echo ${old_url} | sed "s|${{ env.REPO_ODO_VERSION }}|${{ env.LATEST_TOOL_RELEASE }}|"`
3333
jq --indent 4 ".tools.odo.platforms.${platform}.url = \"${new_url}\"" src/main/resources/tools.json > src/main/resources/tools.json.new

0 commit comments

Comments
 (0)