AUTOMATICALLY initializes a new repository created from a template. This action checks if it is running in a new repository (not the original template), renames files, replaces placeholders, cleans up unwanted files, and self-destructs the setup workflow.
- Auto-Detection: Runs only when a new repository is created from the template.
- File Renaming: Renames specific files (e.g.,
README_TEMPLATE.mdtoREADME.md). - Content Replacement: Automatically replaces
{{REPO_NAME}}with the new repository name in renamed files. - Cleanup: Removes temporary files and the initialization workflow itself after execution.
- Git Identity: Configures a bot user to commit changes.
Add this action to a workflow file (e.g., .github/workflows/setup.yml) in your template repository.
name: Template Setup
on:
push:
branches:
- main
jobs:
setup:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Initialize Template
uses: aretw0/template-initializer@v1
with:
template_repository: aretw0/my-template # REPLACE with your template repo
workflow_filename: .github/workflows/setup.yml # The file identifying THIS workflow
files_to_rename: "README_TEMPLATE.md:README.md" # Optional: Space separated list of old:new
files_to_remove: "LICENSE-TEMPLATE" # Optional: Space separated list of files to remove| Input | Description | Required | Default |
|---|---|---|---|
template_repository |
The owner/repo of the original template. Prevents the action from checking out the template itself. |
Yes | N/A |
workflow_filename |
The path to the workflow file calling this action. It will be deleted after successful initialization. | Yes | N/A |
files_to_rename |
A space-separated list of old_path:new_path pairs. Also replaces {{REPO_NAME}} in the new file. |
No | "" |
files_to_remove |
A space-separated list of files, directories, or glob patterns (e.g., docs/*.md) to delete. |
No | "" |
reset_changelog |
If true, resets CHANGELOG.md to a standard initial header. |
No | false |
reset_version |
If true, resets VERSION file to 0.0.1. |
No | false |
token |
GitHub token for authentication. | No | ${{ github.token }} |