Skip to content

Replace Placeholders #3

Replace Placeholders

Replace Placeholders #3

name: Replace Placeholders
on:
workflow_dispatch:
jobs:
replace:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Replace placeholders safely
run: |
REPO_NAME="${GITHUB_REPOSITORY##*/}"
REPO_NAME_LOWER=$(echo "$REPO_NAME" | tr '[:upper:]' '[:lower:]')
echo "Replacing placeholders..."
# Find only regular text files, exclude .git and binaries
find . \
-type f \
-not -path "./.git/*" \
-exec grep -Iq . {} \; \
-exec sed -i "s/__REPO_NAME_LOWER__/${REPO_NAME_LOWER}/g" {} \; \
-exec sed -i "s/__REPO_NAME__/${REPO_NAME}/g" {} \;
# Create marker file so it only runs once if needed
touch .init_done
- name: Commit and push changes
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add -A
git commit -m "Replace placeholders with repo name values"
git push