Skip to content

Fix searching short name #14

Fix searching short name

Fix searching short name #14

Workflow file for this run

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
env:
FILES_TO_SYNC: "README.md"
MY_NAME: "Nikolas Garofil (Using GitHub Actions)"
MY_EMAIL: "[email protected]"
permissions:
contents: write
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup git
run: |
git config --global user.email "$MY_EMAIL"
git config --global user.name "$MY_NAME"
-
name: Update README.md in all other branches
shell: bash
run: |
echo "Finding all branches"
BRANCHES=$(git branch --format='%(refname:short)' -r | grep -v 'origin/HEAD' | sed 's/origin\///' | xargs)
CURRENT_BRANCH=$(echo ${{ github.ref }} | sed 's/refs\/heads\///')
echo "We will sync the following files: \"$FILES_TO_SYNC\" from $CURRENT_BRANCH to all other branches being: \"$BRANCHES\""
for branch in $BRANCHES; do
echo "Checking out $branch"
if [[ $branch == $CURRENT_BRANCH ]]; then
echo "Skipping $branch because the new version of README.md comes from this branch"
else
git checkout $branch
for file in $FILES_TO_SYNC; do
echo "Syncing $file from $CURRENT_BRANCH to $branch"
git checkout $CURRENT_BRANCH -- $file
git add $file
done
echo "Committing and pushing changes"
git commit -m "Sync $FILES_TO_SYNC from $CURRENT_BRANCH"
git push origin $branch
fi
done