|
| 1 | +name: "Create" |
| 2 | + |
| 3 | +# The workflow will run when the "Use this template" button is used |
| 4 | +on: |
| 5 | + push: |
| 6 | + |
| 7 | +jobs: |
| 8 | + create: |
| 9 | + # We only run this action when the repository isn't the template repository. References: |
| 10 | + # - https://docs.github.com/en/actions/learn-github-actions/contexts |
| 11 | + # - https://docs.github.com/en/actions/learn-github-actions/expressions |
| 12 | + if: ${{ !github.event.repository.is_template }} |
| 13 | + permissions: "write-all" |
| 14 | + runs-on: "ubuntu-latest" |
| 15 | + steps: |
| 16 | + - name: "Check out the repo" |
| 17 | + uses: "actions/checkout@v4" |
| 18 | + |
| 19 | + - name: "Update package.json" |
| 20 | + env: |
| 21 | + GITHUB_REPOSITORY_DESCRIPTION: ${{ github.event.repository.description }} |
| 22 | + run: |
| 23 | + ./.github/scripts/rename.sh "$GITHUB_REPOSITORY" "$GITHUB_REPOSITORY_OWNER" "$GITHUB_REPOSITORY_DESCRIPTION" |
| 24 | + |
| 25 | + - name: "Add rename summary" |
| 26 | + run: | |
| 27 | + echo "## Commit result" >> $GITHUB_STEP_SUMMARY |
| 28 | + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY |
| 29 | +
|
| 30 | + - name: "Remove files not needed in the user's copy of the template" |
| 31 | + run: | |
| 32 | + rm -rf "./.github/scripts/" |
| 33 | + rm -f "./.github/workflows/create.yml" |
| 34 | +
|
| 35 | + - name: "Add remove summary" |
| 36 | + run: | |
| 37 | + echo "## Remove result" >> $GITHUB_STEP_SUMMARY |
| 38 | + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY |
| 39 | +
|
| 40 | + - name: "Update commit" |
| 41 | + uses: "stefanzweifel/git-auto-commit-action@v5" |
| 42 | + with: |
| 43 | + commit_message: "feat: initial commit" |
| 44 | + commit_options: "--amend" |
| 45 | + push_options: "--force" |
| 46 | + skip_fetch: true |
| 47 | + |
| 48 | + - name: "Add commit summary" |
| 49 | + run: | |
| 50 | + echo "## Commit result" >> $GITHUB_STEP_SUMMARY |
| 51 | + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY |
0 commit comments