auto-go-upgrade #164
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: auto-go-upgrade | |
concurrency: auto-go-upgrade | |
on: | |
workflow_dispatch: {} | |
schedule: | |
# 10pm daily | |
- cron: '0 22 * * *' | |
jobs: | |
go_upgrade_pr: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Fail if branch is not main | |
if: github.ref != 'refs/heads/main' | |
run: | | |
echo "This workflow should not be run on a branch other than main." | |
exit 1 | |
- uses: actions/checkout@v4 | |
- run: | | |
git checkout -B "go-version-bump" | |
./scripts/patch_go_version.sh | |
- id: is-up-to-date | |
shell: bash | |
run: | | |
git_status=$(git status -s) | |
is_up_to_date="true" | |
if [ -n "$git_status" ]; then | |
is_up_to_date="false" | |
echo "The following changes will be committed:" | |
echo "$git_status" | |
fi | |
echo "result=$is_up_to_date" >> "$GITHUB_OUTPUT" | |
- if: ${{ steps.is-up-to-date.outputs.result != 'true' }} | |
run: | | |
git config --global user.name "jetstack-bot" | |
git config --global user.email "jetstack-bot@users.noreply.github.com" | |
git commit -a -m "BOT: update vendored go to latest available patch version" --signoff | |
git push -f origin go-version-bump | |
- if: ${{ steps.is-up-to-date.outputs.result != 'true' }} | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { repo, owner } = context.repo; | |
const pulls = await github.rest.pulls.list({ | |
owner: owner, | |
repo: repo, | |
head: owner + ':go-version-bump', | |
base: 'main', | |
state: 'open', | |
}); | |
if (pulls.data.length < 1) { | |
await github.rest.pulls.create({ | |
title: '[CI] Bump vendored Go version to latest patch version', | |
owner: owner, | |
repo: repo, | |
head: 'go-version-bump', | |
base: 'main', | |
body: [ | |
'This PR is auto-generated to bump the vendored go version in the tools module to the latest available patch version', | |
].join('\n'), | |
}); | |
} |