From 627fcec6b9b08ec257d2aaa4cecbbcaf54b248c2 Mon Sep 17 00:00:00 2001 From: Roland Grunberg Date: Wed, 22 Mar 2023 16:47:39 -0400 Subject: [PATCH] Routinely check for a new version of odo. Signed-off-by: Roland Grunberg --- .github/workflows/check-odo.yml | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/check-odo.yml diff --git a/.github/workflows/check-odo.yml b/.github/workflows/check-odo.yml new file mode 100644 index 000000000..861c15fa6 --- /dev/null +++ b/.github/workflows/check-odo.yml @@ -0,0 +1,44 @@ +name: check-odo + +on: + schedule: + - cron: "0 8 * * *" +jobs: + check-odo-repo: + runs-on: ubuntu-latest + env: + TOOL_REPO: redhat-developer/odo + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Check Out Code + uses: actions/checkout@v2 + - name: Get latest ODO version + run: | + echo "REPO_ODO_VERSION=$(cat src/tools.json | jq -r .odo.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 | sed 's|v||')" >> $GITHUB_ENV + echo "LATEST_TOOL_URL=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .url)" >> $GITHUB_ENV + - name: Find existing PR for ODO version + run: | + echo PR_EXISTS=$(gh pr --repo ${{ github.repository }} list --state all --search "update odo ${{env.LATEST_TOOL_RELEASE}} in:title" --json url | jq length) >> $GITHUB_ENV + - name: Update src/tools.json with latest odo version + if: ${{ (env.LATEST_TOOL_RELEASE != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }} + run: | + jq --indent 4 '.odo.version = "${{ env.LATEST_TOOL_RELEASE }}"' src/tools.json | jq --indent 4 '.odo.versionRange = "^${{ env.LATEST_TOOL_RELEASE }}"' | jq --indent 4 '.odo.versionRangeLabel = "version >= ${{ env.LATEST_TOOL_RELEASE }}"' > src/tools.json.new + mv src/tools.json.new src/tools.json + for platform in win32 darwin linux; do + old_url=`jq -r .odo.platform.${platform}.url src/tools.json` + new_url=`echo ${old_url} | sed "s|${{ env.REPO_ODO_VERSION }}|${{ env.LATEST_TOOL_RELEASE }}|"` + checksum=`curl -s ${new_url}.sha256` + jq --indent 4 ".odo.platform.${platform}.url = \"${new_url}\"" src/tools.json | jq --indent 4 ".odo.platform.${platform}.sha256sum = \"${checksum}\"" > src/tools.json.new + mv src/tools.json.new src/tools.json + done + - name: Create pull request + if: ${{ (env.LATEST_TOOL_RELEASE != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }} + run: | + git config --global user.email "openshifttools-bot@users.noreply.github.com" + git config --global user.name "openshifttools-bot" + git checkout -b "odo-${{ env.LATEST_TOOL_RELEASE }}" + git commit -am "Update odo to ${{ env.LATEST_TOOL_RELEASE }}" + git push origin "odo-${{ env.LATEST_TOOL_RELEASE }}" + gh pr create --title "Update odo to ${{ env.LATEST_TOOL_RELEASE }}" --body "See ${{ env.LATEST_TOOL_URL }}"