check-odo #543
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-odo | |
on: | |
schedule: | |
- cron: "0 8 * * *" | |
workflow_dispatch: | |
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@v4 | |
- name: Get latest ODO version | |
run: | | |
echo "REPO_ODO_VERSION=$(cat src/main/resources/tools.json | jq -r .tools.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 open --search "fix: update odo ${{env.LATEST_TOOL_RELEASE}} in:title" --json url | jq length) >> $GITHUB_ENV | |
- name: Update tools.json with latest odo version | |
if: ${{ (env.LATEST_TOOL_RELEASE != '') && (env.LATEST_TOOL_RELEASE != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }} | |
run: | | |
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 | |
mv src/main/resources/tools.json.new src/main/resources/tools.json | |
for platform in win osx \"osx-aarch64\" lnx \"lnx-arm64\"; do | |
old_url=`jq -r .tools.odo.platforms.${platform}.url src/main/resources/tools.json` | |
new_url=`echo ${old_url} | sed "s|${{ env.REPO_ODO_VERSION }}|${{ env.LATEST_TOOL_RELEASE }}|"` | |
jq --indent 4 ".tools.odo.platforms.${platform}.url = \"${new_url}\"" src/main/resources/tools.json > 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_ODO_VERSION) && (env.PR_EXISTS == 0) }} | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Action" | |
git checkout -b "odo-${{ env.LATEST_TOOL_RELEASE }}" | |
git commit -am "fix: Update odo to ${{ env.LATEST_TOOL_RELEASE }}" | |
git push origin "odo-${{ env.LATEST_TOOL_RELEASE }}" | |
gh pr create --title "fix: Update odo to ${{ env.LATEST_TOOL_RELEASE }}" --body "See ${{ env.LATEST_TOOL_URL }}" |