-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f1d8c8
commit 30460de
Showing
3 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Check GitHub CLI Version | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' # Runs daily at midnight UTC | ||
workflow_dispatch: # Allows manual triggering | ||
|
||
jobs: | ||
check-version: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Get latest gh CLI version | ||
id: get_version | ||
run: | | ||
LATEST_VERSION=$(curl -s https://api.github.com/repos/cli/cli/releases/latest | jq -r .tag_name | sed 's/^v//') | ||
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV | ||
echo "Latest version: $LATEST_VERSION" | ||
- name: Check and update version | ||
run: | | ||
# Read current version from Dockerfile | ||
CURRENT_VERSION=$(grep -oP 'BUILD_GITHUB_CLI_VERSION=\K[0-9.]+' src/Dockerfile) | ||
echo "Current version: $CURRENT_VERSION" | ||
if [ "$CURRENT_VERSION" != "${{ env.LATEST_VERSION }}" ]; then | ||
echo "Updating version from $CURRENT_VERSION to ${{ env.LATEST_VERSION }}" | ||
# Create new branch | ||
git checkout -b update-gh-cli-version-${{ env.LATEST_VERSION }} | ||
# Update Dockerfile | ||
sed -i "s/BUILD_GITHUB_CLI_VERSION=$CURRENT_VERSION/BUILD_GITHUB_CLI_VERSION=${{ env.LATEST_VERSION }}/" src/Dockerfile | ||
# Update workflow file | ||
sed -i "s/- $CURRENT_VERSION/- ${{ env.LATEST_VERSION }}/" .github/workflows/service_docker-build-and-publish.yml | ||
# Create commit and push | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git add src/Dockerfile .github/workflows/service_docker-build-and-publish.yml | ||
git commit -m "chore: update GitHub CLI version to ${{ env.LATEST_VERSION }}" | ||
git push origin update-gh-cli-version-${{ env.LATEST_VERSION }} | ||
# Create PR | ||
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}" | ||
gh pr create \ | ||
--title "chore: update GitHub CLI version to ${{ env.LATEST_VERSION }}" \ | ||
--body "Automated PR to update GitHub CLI version from $CURRENT_VERSION to ${{ env.LATEST_VERSION }}" \ | ||
--label "dependencies" \ | ||
--base main \ | ||
--head update-gh-cli-version-${{ env.LATEST_VERSION }} \ | ||
--auto-merge | ||
else | ||
echo "Already using the latest version ($CURRENT_VERSION)" | ||
fi |
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
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