Update template-cleanup.yml #4
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: Template Cleanup | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
template-cleanup: | |
name: Template Cleanup | |
runs-on: ubuntu-latest | |
if: github.event.repository.name != 'laravel-package-template' | |
permissions: | |
contents: write | |
steps: | |
- name: Fetch Sources | |
uses: actions/checkout@v3 | |
- name: Cleanup | |
run: | | |
# Debugging | |
echo "Repository name: $GITHUB_REPOSITORY" | |
# Get name portion from repository name | |
NAME="${GITHUB_REPOSITORY##*/}" | |
echo "Base name: $NAME" | |
# Generate name versions from base | |
KEBAB=$(echo $NAME | tr -s -c '[:alpha:][:cntrl:]' ' ' | tr '[:upper:]' '[:lower:]' | tr ' ' '-') | |
STUDLY="$(echo "$NAME" | awk '{split($0,a,"[_ -]"); for(i=1;i<=length(a);++i) printf "%s",(length(a[i]) > 0 ? toupper(substr(a[i],1,1)) tolower(substr(a[i],2)) : "")}')" | |
# Debugging | |
echo "Kebab name: $KEBAB" | |
echo "Studly name: $STUDLY" | |
# Replace placeholder names | |
find src -type f -exec sed -i "s/laravel-package-template/$KEBAB/g" {} + | |
find src -type f -exec sed -i "s/LaravelPackageTemplate/$STUDLY/g" {} + | |
# Rename files | |
mv .idea/laravel-package-template.iml .idea/$KEBAB.iml | |
mv config/config.php config/$KEBAB.php | |
# Cleanup | |
rm -f .github/workflows/template-cleanup.yml | |
- name: Commit files | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add . | |
git commit -m "Template cleanup" | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
branch: main | |
github_token: ${{ secrets.GITHUB_TOKEN }} |