44 workflow_dispatch :
55 inputs :
66 new_project_name :
7- description : ' The new name for the project.'
7+ description : ' The name for the new project.'
88 required : true
99 default : ' New Project Name'
1010 project_description :
@@ -35,14 +35,14 @@ jobs:
3535 git config user.name "github-actions"
3636 git config user.email "github-actions@github.com"
3737
38- - name : Set project name variables
38+ - name : Set project variables
3939 id : set-variables
4040 run : |
4141 # Convert the project name to snake_case for use in filenames and other contexts.
4242 PROJECT_NAME_LOWER=$(echo "${{ github.event.inputs.new_project_name }}" | tr '[:upper:]' '[:lower:]' | tr ' ' '_')
4343 echo "project_name_lower=$PROJECT_NAME_LOWER" >> $GITHUB_OUTPUT
4444
45- - name : Replace project name placeholders
45+ - name : Replace project template placeholders
4646 run : |
4747 # This command finds all files and uses 'sed' to replace all the placeholders.
4848 # The sed delimiter is changed from '/' to '|' to safely handle path names.
@@ -54,13 +54,22 @@ jobs:
5454 -e "s|{{CPACK_PACKAGE_CONTACT}}|${{ github.event.inputs.cpack_package_contact }}|g" \
5555 {} +
5656
57- - name : Create a pull request with the new name
57+ - name : Remove template-specific files and instructions
58+ run : |
59+ rm -f UNLICENSE
60+ LINE=$(grep -n -m 1 "^---" README.md | cut -d: -f1)
61+ if [ -n "$LINE" ]; then
62+ if tail -n +$LINE README.md | grep -q "## ⚙️ How to Use This Template"; then
63+ sed -i "$LINE,\$d" README.md
64+ fi
65+ fi
66+
67+ - name : Create a pull request with configured project
5868 uses : peter-evans/create-pull-request@v6
5969 with :
60- title : ' Update project name to "${{ github.event.inputs.new_project_name }}" '
61- commit-message : ' feat: Update project name to ${{ github.event.inputs.new_project_name }} '
70+ title : ' feat: Configure project from template '
71+ commit-message : ' feat: Configure project from template '
6272 body : |
63- This pull request automatically updates all instances of the project name
64- placeholder (`{{PROJECT_NAME}}`) and other related placeholders with the new information you provided.
65- branch : update-project-name-${{ github.run_number }}
66- token : ${{ secrets.GITHUB_TOKEN }}
73+ This pull request configures the project from the template with the information you provided.
74+ branch : configure-project-${{ github.run_number }}
75+ token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments