Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 49 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# 🚀 GitHub Action for Committing Changes to Repository


### 🏗️ Multi-Architecture Support: `amd64` and `aarch64/arm64`


### ⚠️ Recent Changes in v0.11.0
- **Force behavior updated**: `force: true` now uses `git push --force` (breaking change)
- **New parameter**: `force_with_lease` for safer force pushing with `--force-with-lease`
Expand All @@ -10,9 +12,10 @@

A powerful GitHub Action for automatically committing and pushing changes back to your repository. Perfect for automation workflows and integrates seamlessly with [devops-infra/action-pull-request](https://github.com/devops-infra/action-pull-request).


## 📦 Available on
- **Docker Hub:** [devopsinfra/action-commit-push:latest](https://hub.docker.com/repository/docker/devopsinfra/action-commit-push)
- **GitHub Packages:** [ghcr.io/devops-infra/action-commit-push/action-commit-push:latest](https://github.com/orgs/devops-infra/packages/container/package/action-commit-push)
- **GitHub Packages:** [ghcr.io/devops-infra/action-commit-push:latest](https://github.com/orgs/devops-infra/packages/container/package/action-commit-push)


## ✨ Features
Expand Down Expand Up @@ -44,40 +47,40 @@ A powerful GitHub Action for automatically committing and pushing changes back t
## 📖 API Reference

```yaml
- name: Run the Action
uses: devops-infra/action-commit-push@master
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
add_timestamp: true
commit_prefix: "[AUTO]"
commit_message: "Automatic commit"
force: false
force_with_lease: false
target_branch: update/version
- name: Run the Action
uses: devops-infra/action-commit-push@master
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
add_timestamp: true
commit_prefix: "[AUTO]"
commit_message: "Automatic commit"
force: false
force_with_lease: false
target_branch: update/version
```


### 🔧 Input Parameters

| Input Variable | Required | Default | Description |
| ------------------- | -------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| github_token | Yes | `""` | Personal Access Token for GitHub for pushing the code. |
| add_timestamp | No | `false` | Whether to add the timestamp to a new branch name. Uses format `%Y-%m-%dT%H-%M-%SZ`. |
| amend | No | `false` | Whether to make an amendment to the previous commit (`--amend`). Can be combined with `commit_message` to change the commit message. |
| commit_prefix | No | `""` | Prefix added to commit message. Combines with `commit_message`. |
| commit_message | No | `""` | Commit message to set. Combines with `commit_prefix`. Can be used with `amend` to change the commit message. |
| force | No | `false` | Whether to use force push (`--force`). Use only when you need to overwrite remote changes. Potentially dangerous. |
| force_with_lease | No | `false` | Whether to use force push with lease (`--force-with-lease`). Safer than `force` as it checks for remote changes. Set `fetch-depth: 0` for `actions/checkout`. |
| no_edit | No | `false` | Whether to not edit commit message when using amend (`--no-edit`). |
| organization_domain | No | `github.com` | GitHub Enterprise domain name. |
| target_branch | No | *current branch* | Name of a new branch to push the code into. Creates branch if not existing. |
| Input Variable | Required | Default | Description |
|---------------------|----------|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| github_token | Yes | `""` | Personal Access Token for GitHub for pushing the code. |
| add_timestamp | No | `false` | Whether to add the timestamp to a new branch name. Uses format `%Y-%m-%dT%H-%M-%SZ`. |
| amend | No | `false` | Whether to make an amendment to the previous commit (`--amend`). Can be combined with `commit_message` to change the commit message. |
| commit_prefix | No | `""` | Prefix added to commit message. Combines with `commit_message`. |
| commit_message | No | `""` | Commit message to set. Combines with `commit_prefix`. Can be used with `amend` to change the commit message. |
| force | No | `false` | Whether to use force push (`--force`). Use only when you need to overwrite remote changes. Potentially dangerous. |
| force_with_lease | No | `false` | Whether to use force push with lease (`--force-with-lease`). Safer than `force` as it checks for remote changes. Set `fetch-depth: 0` for `actions/checkout`. |
| no_edit | No | `false` | Whether to not edit commit message when using amend (`--no-edit`). |
| organization_domain | No | `github.com` | GitHub Enterprise domain name. |
| target_branch | No | *current branch* | Name of a new branch to push the code into. Creates branch if not existing. |

### 📤 Output Parameters

| Output | Description |
| ------------- | -------------------------------------------------------------------------- |
| Output | Description |
|---------------|--------------------------------------------------------------------------|
| files_changed | List of changed files, as returned by `git diff --staged --name-status`. |
| branch_name | Name of the branch code was pushed into. |
| branch_name | Name of the branch code was pushed into. |


## 💻 Usage Examples
Expand All @@ -95,12 +98,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Change something
run: |
find . -type f -name "*.md" -print0 | xargs -0 sed -i "s/foo/bar/g"
- name: Commit and push changes
uses: devops-infra/action-commit-push@master
uses: devops-infra/action-commit-push@v0.11
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: "Replace foo with bar"
Expand All @@ -119,18 +122,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Change something
run: |
find . -type f -name "*.md" -print0 | xargs -0 sed -i "s/foo/bar/g"
- name: Commit and push changes
uses: devops-infra/action-commit-push@master
uses: devops-infra/action-commit-push@v.11
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_prefix: "[AUTO-COMMIT] "
commit_message: "Replace foo with bar"
- name: Create pull request
uses: devops-infra/action-pull-request@master
uses: devops-infra/action-pull-request@v0.6
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
body: "**Automated pull request**<br><br>Replaced foo with bar"
Expand All @@ -156,14 +159,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository with full history
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 0 # Required for force_with_lease
- name: Make some changes
run: |
echo "Additional content" >> README.md
- name: Amend and force push with lease
uses: devops-infra/action-commit-push@master
uses: devops-infra/action-commit-push@v0.11
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: ${{ github.event.inputs.new_commit_message }}
Expand Down Expand Up @@ -200,38 +203,35 @@ When using `amend: true`, you have several options for handling the commit messa
**💡 Note:** Amending works even without file changes - useful for just changing commit messages!


## 🎯 Version Usage Options
## 🏷️ Version Tags: vX, vX.Y, vX.Y.Z

You can use this action in different ways depending on your needs:
This action supports three tag levels for flexible versioning:

### 🔄 Latest Version (Recommended)
- **`vX`**: Always points to the latest patch of a major version (e.g., `v1` → `v1.2.3`).
_Benefit: Get all latest fixes for a major version automatically._

```yaml
- uses: devops-infra/action-commit-push@master
```

Always uses the latest release. Automatically gets new features and fixes.

### 📌 Pinned Version (Stable)
- **`vX.Y`**: Always points to the latest patch of a minor version (e.g., `v1.2` → `v1.2.3`).
_Benefit: Stay on a minor version, always up-to-date with bugfixes._

```yaml
- uses: devops-infra/action-commit-push@v0.11
```
- **`vX.Y.Z`**: Fixed to a specific release (e.g., `v1.2.3`).
_Benefit: Full reproducibility—never changes._

Uses a specific version. More predictable but requires manual updates.
**Use the tag depth that matches your stability needs.**


## ⚠️ Force Push Options

This action provides two force push options for different scenarios:


### 🛡️ `force_with_lease` (Recommended)
- Uses `git push --force-with-lease`
- **Safer option** that checks if someone else has pushed changes to the remote branch
- Prevents accidentally overwriting other people's work
- **Required:** Set `fetch-depth: 0` in your `actions/checkout` step
- **Use case:** Amending commits, rebasing, or other history modifications


### ⚡ `force` (Use with Caution)
- Uses `git push --force`
- **Potentially dangerous** as it will overwrite remote changes unconditionally
Expand All @@ -243,7 +243,7 @@ This action provides two force push options for different scenarios:

## 🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Contributions are welcome! Please feel free to submit a Pull Request. Refer to the [CONTRIBUTING](https://github.com/devops-infra/.github/blob/master/CONTRIBUTING.md) for guidelines.


## 📄 License
Expand All @@ -259,6 +259,5 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
## 💬 Support

If you have any questions or need help, please:
- 📝 Create an [issue](https://github.com/devops-infra/action-commit-push/issues)
- 💬 Start a [discussion](https://github.com/devops-infra/action-commit-push/discussions)
- 📝 Create an [issue](https://github.com/devops-infra/template-action/issues)
- 🌟 Star this repository if you find it useful!