use-template.yml 1.7 KB

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