Skip to content

Update template-cleanup.yml #5

Update template-cleanup.yml

Update template-cleanup.yml #5

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 . -type f -not -name "template-cleanup.yml" -exec sed -i "s/laravel-package-template/$KEBAB/g" {} +
find . -type f -not -name "template-cleanup.yml" -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 "action@github.com"
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 }}