This document contains detailed examples of how to use the Go Git Commit Action in various scenarios.
Simple commit and push workflow:
name: Auto Commit Workflow
on: [push]
permissions:
contents: write
jobs:
commit:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Auto Commit Changes
uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
commit_message: Auto commit by GitHub Actions
branch: main
repository_path: path/to/repo # Optional
file_pattern: '*.md' # Example: commit only markdown files
github_token: ${{ secrets.GITHUB_TOKEN }}name: Create Tag
on: [workflow_dispatch]
permissions:
contents: write
jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT_TOKEN }}
- name: Create Git Tag
uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
tag_name: v1.0.0
tag_message: Release version 1.0.0 # Optional for annotated tags
github_token: ${{ secrets.PAT_TOKEN }}name: Delete Tag
on: [workflow_dispatch]
permissions:
contents: write
jobs:
delete-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT_TOKEN }}
- name: Delete Git Tag
uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
tag_name: v1.0.0
delete_tag: true
github_token: ${{ secrets.PAT_TOKEN }}Create tags pointing to specific commits, other tags, or branches:
name: Create Tag with Reference
on: [workflow_dispatch]
permissions:
contents: write
jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Tag specific commit
- name: Create Git Tag at Commit
uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
tag_name: v1
tag_reference: ${{ github.sha }}
github_token: ${{ secrets.PAT_TOKEN }}
# Tag from another tag
- name: Create Git Tag from Tag
uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
tag_name: latest
tag_reference: v1.0.2
github_token: ${{ secrets.PAT_TOKEN }}
# Tag from branch
- name: Create Git Tag from Branch
uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
tag_name: stable
tag_reference: main
github_token: ${{ secrets.PAT_TOKEN }}Use an existing branch for PR:
- uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
create_pr: true
auto_branch: false
pr_branch: feature/my-branch
pr_base: main
github_token: ${{ secrets.PAT_TOKEN }}Automatically create a timestamped branch:
- uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
create_pr: true
auto_branch: true
pr_branch: feature/my-branch # Base for auto-generated branch
pr_base: main
github_token: ${{ secrets.PAT_TOKEN }}- uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
create_pr: true
pr_branch: feature/my-branch
pr_base: main
pr_title: "feat: my custom PR title"
pr_labels: "enhancement,automated,test"
pr_body: |
## Custom Pull Request
This PR was automatically created.
### Changes
- Feature 1
- Feature 2
github_token: ${{ secrets.PAT_TOKEN }}- uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
create_pr: true
auto_branch: true
pr_branch: feature/my-branch
pr_base: main
delete_source_branch: true
github_token: ${{ secrets.PAT_TOKEN }}- uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
create_pr: true
pr_branch: feature/my-branch
pr_base: main
skip_if_empty: true
github_token: ${{ secrets.PAT_TOKEN }}- uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
create_pr: true
pr_branch: feature/my-branch
pr_base: main
pr_closed: true
pr_title: "Auto Close PR Example"
pr_body: "This PR will be automatically closed"
github_token: ${{ secrets.PAT_TOKEN }}Test PR creation without actually creating one:
- uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
create_pr: true
pr_branch: feature/my-branch
pr_base: main
pr_title: "Test PR Dry Run"
pr_labels: "test,automated"
pr_dry_run: true
github_token: ${{ secrets.PAT_TOKEN }}Commit multiple file types:
- uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
commit_message: "chore: update multiple file types"
branch: main
file_pattern: "docs/*.md src/*.go *.yaml"
github_token: ${{ secrets.GITHUB_TOKEN }}- uses: somaz94/go-git-commit-action@v1
with:
user_email: actions@github.com
user_name: GitHub Actions
commit_message: "chore: update configuration and documentation"
branch: main
repository_path: "."
file_pattern: "config/*.yaml docs/*.md src/util/*.js"
github_token: ${{ secrets.GITHUB_TOKEN }}