-
-
Save sergekukharev/4f6392fec7a9f7158b515f5090999898 to your computer and use it in GitHub Desktop.
Update Ubuntu runners
This file contains hidden or 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
#!/bin/bash | |
# Configuration | |
SEARCH_STRING="runs-on: ubuntu-20.04" | |
REPLACE_STRING="runs-on: ubuntu-24.04" | |
REPO_LIST="repo1 repo2 repo3" # List of repositories to update | |
BRANCH_PREFIX="update-ubuntu-version" | |
for repo in $REPO_LIST; do | |
# 1. Go to repo directory and reset it | |
cd "/path/to/you/$repo" | |
# git reset --hard | |
git checkout main | |
git pull | |
# 2. Create new branch | |
git checkout -b "$BRANCH_PREFIX-$(date +%Y%m%d)" | |
# 3. Find and replace | |
files_to_update=$(grep -l "$SEARCH_STRING" -r .github/) | |
if [ -n "$files_to_update" ]; then | |
# 4. Replace in all found files | |
for file in $files_to_update; do | |
sed -i '' "s|$SEARCH_STRING|$REPLACE_STRING|g" "$file" | |
done | |
# 5. Commit and push | |
git add . | |
git commit -m "Update ubuntu version in workflows" | |
git push -u origin "$BRANCH_PREFIX-$(date +%Y%m%d)" | |
# 6. Create PR | |
gh pr create \ | |
--title "Update Ubuntu version in workflows" \ | |
--body "Updates ubuntu version from 20.04 to 24.04 in workflow files" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment