Skip to content

Commit ac37bf1

Browse files
committed
Routinely check for a new version of odo.
Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
1 parent 895c510 commit ac37bf1

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/check-odo.yml

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

0 commit comments

Comments
 (0)