|
| 1 | +name: check-odo |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 8 * * *" |
| 6 | +jobs: |
| 7 | + check-odo-repo: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + env: |
| 10 | + TOOL_REPO: redhat-developer/odo |
| 11 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 12 | + steps: |
| 13 | + - name: Check Out Code |
| 14 | + uses: actions/checkout@v2 |
| 15 | + - name: Get latest ODO version |
| 16 | + run: | |
| 17 | + echo "REPO_ODO_VERSION=$(cat src/tools.json | jq -r .odo.version)" >> $GITHUB_ENV |
| 18 | + LATEST_TOOL_RELEASE_RESP=$(gh release --repo ${{ env.TOOL_REPO }} view --json tagName,url) |
| 19 | + echo "LATEST_TOOL_RELEASE=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .tagName | sed 's|v||')" >> $GITHUB_ENV |
| 20 | + echo "LATEST_TOOL_URL=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .url)" >> $GITHUB_ENV |
| 21 | + - name: Find existing PR for ODO version |
| 22 | + run: | |
| 23 | + 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 |
| 24 | + - name: Update src/tools.json with latest odo version |
| 25 | + if: ${{ (env.LATEST_TOOL_RELEASE != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }} |
| 26 | + run: | |
| 27 | + 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 |
| 28 | + mv src/tools.json.new src/tools.json |
| 29 | + for platform in win32 darwin linux; do |
| 30 | + old_url=`jq -r .odo.platform.${platform}.url src/tools.json` |
| 31 | + new_url=`echo ${old_url} | sed "s|${{ env.REPO_ODO_VERSION }}|${{ env.LATEST_TOOL_RELEASE }}|"` |
| 32 | + checksum=`curl -s ${new_url}.sha256` |
| 33 | + jq --indent 4 ".odo.platform.${platform}.url = \"${new_url}\"" src/tools.json | jq --indent 4 ".odo.platform.${platform}.sha256sum = \"${checksum}\"" > src/tools.json.new |
| 34 | + mv src/tools.json.new src/tools.json |
| 35 | + done |
| 36 | + - name: Create pull request |
| 37 | + if: ${{ (env.LATEST_TOOL_RELEASE != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }} |
| 38 | + run: | |
| 39 | + git config --global user.email "openshifttools-bot@users.noreply.github.com" |
| 40 | + git config --global user.name "openshifttools-bot" |
| 41 | + git checkout -b "odo-${{ env.LATEST_TOOL_RELEASE }}" |
| 42 | + git commit -am "Update odo to ${{ env.LATEST_TOOL_RELEASE }}" |
| 43 | + git push origin "odo-${{ env.LATEST_TOOL_RELEASE }}" |
| 44 | + gh pr create --title "Update odo to ${{ env.LATEST_TOOL_RELEASE }}" --body "See ${{ env.LATEST_TOOL_URL }}" |
0 commit comments