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: Update README.md on all branches | |
#Run this workflow every time a push event occurs on the main branch, because almost all commits on the main branch will update the README.md file. | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
update-readme: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
- | |
name: Update README.md in all other branches | |
env: | |
FILES_TO_SYNC: README.md | |
run: | | |
ech "We will sync the following files: $FILES_TO_SYNC from ${{ github.ref.short }} to all other branches" | |
for branch in $(git branch --format='%(refname:short)'); do | |
echo "Checking out $branch" | |
if [ ${{ github.ref.short }} == $branch ]; then | |
echo "Skipping $branch because the new version of README.md comes from this branch" | |
continue | |
else | |
git checkout $branch | |
for file in $FILES_TO_SYNC; do | |
echo "Syncing $file from ${{ github.ref }} to $branch" | |
git checkout ${{ github.ref }} -- $file | |
git add $file | |
git commit -m "Sync README.md from ${{ github.ref }}" | |
git push origin $branch | |
done | |
fi | |
done |