-
Notifications
You must be signed in to change notification settings - Fork 2
GHA to update jib image with the latest version #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| name: Auto-Update Jib Base Image | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| schedule: | ||
| - cron: "0 0 * * 5" # Every Friday at Midnight | ||
|
|
||
| jobs: | ||
| update_build_gradle: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install GitHub CLI | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install gh | ||
|
|
||
| - name: Update build.gradle and create PR | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| # Extract current version from JShellAPI build.gradle | ||
| gradle_file="JShellWrapper/build.gradle" | ||
| current_version=$(grep -oP "(?<=from\.image\s=\s'eclipse-temurin:)\d+" $gradle_file) | ||
|
|
||
| if [ -z "$current_version" ]; then | ||
| echo "Failed to extract version from $gradle_file \"from.image\"" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Fetch the latest eclipse-temurin image | ||
| latest_version=$(curl -s "https://hub.docker.com/v2/repositories/library/eclipse-temurin/tags/?page_size=100" | \ | ||
| jq -r '[.results[].name | select(test("alpine")) | select(test("^[0-9]+"))] | map(capture("^(?<major>[0-9]+)")) | max_by(.major | tonumber) | .major') | ||
|
|
||
|
|
||
| # Check if a new version is available | ||
| if [ "$latest_version" -le "$current_version" ]; then | ||
| echo "No new versions available" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Update the build.gradle with the new version | ||
| sed -i "s/eclipse-temurin:$current_version-alpine/eclipse-temurin:$latest_version-alpine/" $gradle_file | ||
|
|
||
| echo "Updated eclipse-temurin version from $current_version to $latest_version" | ||
|
|
||
| git config --global user.name "github-actions[bot]" | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| branch_name="update-eclipse-temurin-$latest_version" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Find a better name like "JShell Java Version" or "Session Java Version". |
||
| git checkout -b "$branch_name" | ||
|
|
||
| git add "$gradle_file" | ||
| git commit -m "Update eclipse-temurin version to $latest_version" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Find a better name like "Update JShell to Java 23". |
||
|
|
||
| git fetch origin | ||
| git rebase origin/develop | ||
| git push origin "$branch_name" | ||
|
|
||
| gh pr create --title "Update eclipse-temurin version to $latest_version" \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Find a better name like "Update JShell to Java 23". |
||
| --body "This PR updates the eclipse-temurin version in the JShellAPI build.gradle file from $current_version to $latest_version." \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't specify eclipse temurin since that's not what matters. And it's not JShellAPI but JShellWrapper. |
||
| --head "$branch_name" \ | ||
| --base "develop" | ||
Uh oh!
There was an error while loading. Please reload this page.