Initializes a Git repository and sets up version control for your project.
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| args | array | - | |
| command | string | The git command to run | |
| workingDirectory | string | Working directory within the scaffolder workspace to execute the command in |
Output Schema
Usage Examples
Initialize a repository and make the first commit
Use this to initialize a new Git repository for the scaffolded content and create the initial commit. Run after fetching your template with fetch:template.
steps:
- id: fetch
action: fetch:template
name: Fetch service template
input:
url: https://github.com/acme/templates/node-service
targetPath: ./${{ parameters.repoName }}
values:
name: ${{ parameters.repoName }}
owner: ${{ parameters.owner }}
description: ${{ parameters.description }}
- id: git_init
action: git
name: Init git repo
input:
command: init
workingDirectory: ./${{ parameters.repoName }}
- id: git_add_all
action: git
name: Stage all files
input:
command: add
workingDirectory: ./${{ parameters.repoName }}
args:
- "."
- id: git_commit_initial
action: git
name: Initial commit
input:
command: commit
workingDirectory: ./${{ parameters.repoName }}
args:
- "-m"
- "chore: initial scaffold for ${{ parameters.repoName }}"Configure repository-local Git user before committing
Set repository-local user.name and user.email to ensure commits from the scaffolder have a clear author. Useful in CI environments where global Git config is not set.
steps:
- id: fetch
action: fetch:template
name: Fetch template
input:
url: https://github.com/acme/templates/go-service
targetPath: ./${{ parameters.repoName }}
values:
name: ${{ parameters.repoName }}
- id: git_init
action: git
name: Init git repo
input:
command: init
workingDirectory: ./${{ parameters.repoName }}
- id: git_config_name
action: git
name: Set user.name
input:
command: config
workingDirectory: ./${{ parameters.repoName }}
args:
- user.name
- Scaffolder Bot
- id: git_config_email
action: git
name: Set user.email
input:
command: config
workingDirectory: ./${{ parameters.repoName }}
args:
- user.email
- scaffolder-bot@acme.exampleCreate and switch to a feature branch
Create a feature branch after scaffolding to isolate subsequent modifications. This is typically done after initialization.
steps:
- id: fetch
action: fetch:template
name: Fetch template
input:
url: https://github.com/acme/templates/python-service
targetPath: ./${{ parameters.repoName }}
values:
name: ${{ parameters.repoName }}
- id: git_init
action: git
name: Init git repo
input:
command: init
workingDirectory: ./${{ parameters.repoName }}
- id: git_checkout_branch
action: git
name: Create feature branch
input:
command: checkout
workingDirectory: ./${{ parameters.repoName }}
args:
- "-b"
- "feature/${{ parameters.ticketId }}-bootstrap"Add a remote and push the main branch
Add the origin remote and push the main branch to your Git host. Use after an initial commit so there is content to push.
steps:
- id: fetch
action: fetch:template
name: Fetch template
input:
url: https://github.com/acme/templates/java-service
targetPath: ./${{ parameters.repoName }}
values:
name: ${{ parameters.repoName }}
- id: git_init
action: git
name: Init git repo
input:
command: init
workingDirectory: ./${{ parameters.repoName }}
- id: git_add
action: git
name: Stage files
input:
command: add
workingDirectory: ./${{ parameters.repoName }}
args:
- "."
- id: git_commit
action: git
name: Commit files
input:
command: commit
workingDirectory: ./${{ parameters.repoName }}
args:
- "-m"
- "feat: bootstrap ${{ parameters.repoName }}"
- id: git_rename_main
action: git
name: Rename default branch to main
input:
command: branch
workingDirectory: ./${{ parameters.repoName }}
args:
- "-M"
- "main"
- id: git_add_remote
action: git
name: Add origin remote
input:
command: remote
workingDirectory: ./${{ parameters.repoName }}
args:
- add
- origin
- ${{ parameters.repoUrl }}
- id: git_push_main
action: git
name: Push main to origin
input:
command: push
workingDirectory: ./${{ parameters.repoName }}
args:
- "-u"
- origin
- mainTag a release and push tags
Create an annotated tag for a release and push tags to the remote. Use this when cutting a release after your changes are committed.
steps:
- id: fetch
action: fetch:template
name: Fetch template
input:
url: https://github.com/acme/templates/ts-lib
targetPath: ./${{ parameters.repoName }}
values:
name: ${{ parameters.repoName }}
- id: git_init
action: git
name: Init git repo
input:
command: init
workingDirectory: ./${{ parameters.repoName }}
- id: git_add_remote
action: git
name: Add origin remote
input:
command: remote
workingDirectory: ./${{ parameters.repoName }}
args:
- add
- origin
- ${{ parameters.repoUrl }}
- id: git_tag
action: git
name: Create annotated tag
input:
command: tag
workingDirectory: ./${{ parameters.repoName }}
args:
- "-a"
- "v${{ parameters.version }}"
- "-m"
- "Release v${{ parameters.version }}"
- id: git_push_tags
action: git
name: Push tags
input:
command: push
workingDirectory: ./${{ parameters.repoName }}
args:
- "--tags"
- origin