Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: stefanzweifel/git-auto-commit-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.16.0
Choose a base ref
...
head repository: stefanzweifel/git-auto-commit-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.0.0
Choose a head ref

Commits on Dec 2, 2022

  1. Update CHANGELOG

    stefanzweifel authored and github-actions[bot] committed Dec 2, 2022
    Copy the full SHA
    925bbca View commit details

Commits on Dec 22, 2022

  1. Add _log and _set_github_output functions (#273)

    * Add _set_github_output function
    
    * Use _set_github_output in Action
    
    * Add _log function
    
    * Use _log in Action and fix Test Cases
    
    * Update wording in log messages
    
    * Update note about removal of old output syntax
    
    Logic is now encapuslated in a single function. I don’t mind keeping it around until spring / June 2023
    stefanzweifel authored Dec 22, 2022
    Copy the full SHA
    aeb1802 View commit details

Commits on Jan 3, 2023

  1. Copy the full SHA
    86fb2e1 View commit details

Commits on Jan 7, 2023

  1. Copy the full SHA
    fe00d25 View commit details

Commits on Jan 14, 2023

  1. Update README.md

    stefanzweifel authored Jan 14, 2023
    Copy the full SHA
    3663a6f View commit details

Commits on Jan 20, 2023

  1. Update README.md

    Closes #281
    stefanzweifel authored Jan 20, 2023
    Copy the full SHA
    3b94e3d View commit details

Commits on Jan 25, 2023

  1. Copy the full SHA
    92b3981 View commit details
  2. Copy the full SHA
    f44d1cd View commit details

Commits on Feb 11, 2023

  1. Copy the full SHA
    94d6bf9 View commit details
  2. Copy the full SHA
    ccd4d05 View commit details
  3. Mention new permission requirements in usage docs

    Starting February 2nd 2023, GitHub changed the default permissions of the GITHUB_TOKEN to be read-only in all new repositories.[1]
    
    git-auto-commits needs `write`-permissions for the `contents`-key in order to work properly.
    This commits updates the usage section, to mention the need for the permission requirements. The examples have also been updated to reflect that change.
    
    [1]: https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/
    stefanzweifel committed Feb 11, 2023
    Copy the full SHA
    f0b35f0 View commit details
  4. Copy the full SHA
    6656e54 View commit details
  5. Fix Comment in README

    stefanzweifel committed Feb 11, 2023
    Copy the full SHA
    6436584 View commit details

Commits on Feb 13, 2023

  1. Bump bats from 1.8.2 to 1.9.0 (#282)

    Bumps [bats](https://github.com/bats-core/bats-core) from 1.8.2 to 1.9.0.
    - [Release notes](https://github.com/bats-core/bats-core/releases)
    - [Changelog](https://github.com/bats-core/bats-core/blob/master/docs/CHANGELOG.md)
    - [Commits](bats-core/bats-core@v1.8.2...v1.9.0)
    
    ---
    updated-dependencies:
    - dependency-name: bats
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 13, 2023
    Copy the full SHA
    c8254de View commit details

Commits on Feb 15, 2023

  1. Fix docs about using in public forks

    Update docs section about using the Action in public forks.
    
    Add warning about current issue when the forks lives under an organisation.
    
    Mark section about running a workflow in the head repository as outdated, as I was not able to reproduce this in test projects.
    
    See #211 (comment) for more details.
    stefanzweifel committed Feb 15, 2023
    Copy the full SHA
    8e108d7 View commit details
  2. Copy the full SHA
    3a446b7 View commit details

Commits on Mar 28, 2023

  1. Update Test

    stefanzweifel committed Mar 28, 2023
    Copy the full SHA
    0b5f8a5 View commit details

Commits on Apr 3, 2023

  1. Copy the full SHA
    9cc0a1f View commit details

Commits on Jun 23, 2023

  1. Bump github/super-linter from 4 to 5 (#289)

    Bumps [github/super-linter](https://github.com/github/super-linter) from 4 to 5.
    - [Release notes](https://github.com/github/super-linter/releases)
    - [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
    - [Commits](github/super-linter@v4...v5)
    
    ---
    updated-dependencies:
    - dependency-name: github/super-linter
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jun 23, 2023
    Copy the full SHA
    77a7b3f View commit details

Commits on Jul 17, 2023

  1. Bump bats from 1.9.0 to 1.10.0 (#293)

    Bumps [bats](https://github.com/bats-core/bats-core) from 1.9.0 to 1.10.0.
    - [Release notes](https://github.com/bats-core/bats-core/releases)
    - [Changelog](https://github.com/bats-core/bats-core/blob/master/docs/CHANGELOG.md)
    - [Commits](bats-core/bats-core@v1.9.0...v1.10.0)
    
    ---
    updated-dependencies:
    - dependency-name: bats
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jul 17, 2023
    Copy the full SHA
    47a8ad5 View commit details

Commits on Sep 11, 2023

  1. Bump actions/checkout from 3 to 4 (#302)

    Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
    - [Release notes](https://github.com/actions/checkout/releases)
    - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
    - [Commits](actions/checkout@v3...v4)
    
    ---
    updated-dependencies:
    - dependency-name: actions/checkout
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Sep 11, 2023
    Copy the full SHA
    3d1b5e0 View commit details

Commits on Oct 4, 2023

  1. Copy the full SHA
    1094465 View commit details

Commits on Oct 6, 2023

  1. Fix Typo

    stefanzweifel committed Oct 6, 2023
    Copy the full SHA
    43818d5 View commit details
  2. Copy the full SHA
    17a44b0 View commit details
  3. Update node version to node20 (#300)

    Co-authored-by: ryudai.takai
    ryudaitakai authored Oct 6, 2023
    Copy the full SHA
    8756aa0 View commit details
2 changes: 1 addition & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ categories:
- 'changelog:changed'
- title: Deprecated
labels:
- 'changelog:deprecated '
- 'changelog:deprecated'
- title: Removed
labels:
- 'changelog:removed'
11 changes: 8 additions & 3 deletions .github/workflows/git-auto-commit.yml
Original file line number Diff line number Diff line change
@@ -10,17 +10,22 @@ jobs:
git-auto-commit:
runs-on: ubuntu-latest

permissions:
# Give the default GITHUB_TOKEN write permission.
# https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/
contents: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use git-auto-commit-action
id: "auto-commit-action"
uses: ./

- name: "no changes detected"
if: steps.auto-commit-action.outputs.changes_detected == false
if: steps.auto-commit-action.outputs.changes_detected == 'false'
run: "echo \"No changes detected\""

- name: "changes detected"
if: steps.auto-commit-action.outputs.changes_detected == true
if: steps.auto-commit-action.outputs.changes_detected == 'true'
run: "echo \"Changes detected\""
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -9,10 +9,10 @@ jobs:

steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Lint Code Base
uses: github/super-linter@v4
uses: github/super-linter@v5
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_MARKDOWN: false
6 changes: 6 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -8,6 +8,12 @@ on:
jobs:
update_release_draft:
runs-on: ubuntu-latest

permissions:
# Give the default GITHUB_TOKEN write permission.
# https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/
contents: write

steps:
- uses: release-drafter/release-drafter@v5
env:
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install testing dependencies
run: yarn install
8 changes: 7 additions & 1 deletion .github/workflows/update-changelog.yaml
Original file line number Diff line number Diff line change
@@ -8,9 +8,15 @@ jobs:
update:
runs-on: ubuntu-latest

permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# updated CHANGELOG back to the repository.
# https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: master

6 changes: 6 additions & 0 deletions .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
@@ -7,6 +7,12 @@ on:
jobs:
actions-tagger:
runs-on: windows-latest

permissions:
# Give the default GITHUB_TOKEN write permission.
# https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/
contents: write

steps:
- uses: Actions-R-Us/actions-tagger@latest
env:
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,10 +5,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.4...HEAD)
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.16.0...HEAD)

> TBD
## [v4.16.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.4...v4.16.0) - 2022-12-02

### Changed

- Don't commit files when only LF/CRLF changes ([#265](https://github.com/stefanzweifel/git-auto-commit-action/pull/265)) [@ZeroRin](https://github.com/@ZeroRin)
- Update default email address of github-actions[bot] ([#264](https://github.com/stefanzweifel/git-auto-commit-action/pull/264)) [@Teko012](https://github.com/@Teko012)

### Fixed

- Fix link and text for workflow limitation ([#263](https://github.com/stefanzweifel/git-auto-commit-action/pull/263)) [@Teko012](https://github.com/@Teko012)

## [v4.15.4](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.3...v4.15.4) - 2022-11-05

### Fixed
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at hello@stefanzweifel.io. All
reported by contacting the project team at stefan@stefanzweifel.dev. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
158 changes: 116 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -13,14 +13,42 @@ If you want to learn more how this Action works under the hood, check out [this

## Usage

Add the following step at the end of your job, after other steps that might add or change files.
Adding git-auto-commit to your Workflow only takes a couple lines of code.

1. Set the `contents`-permission of the default GITHUB_TOKEN to `true`. (Required to push new commits to the repository)
2. Add the following step at the end of your job, after other steps that might add or change files.

```yaml
- uses: stefanzweifel/git-auto-commit-action@v4
```
Note that the Action has to be used in a Job that runs on a UNIX system (e.g. `ubuntu-latest`).
If you don't use the default permission of the GITHUB_TOKEN, give the Job or Workflow at least the `contents: write` permission.
Your Workflow should look similar to this example.
```yaml
name: Format

on: push

jobs:
format-code:
runs-on: ubuntu-latest

permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write

steps:
- uses: actions/checkout@v4

# Other steps that change files in the repository

# Commit all changed files back to the repository
- uses: stefanzweifel/git-auto-commit-action@v4
```
> **Note**
> The Action has to be used in a Job that runs on a UNIX system (e.g. `ubuntu-latest`).

The following is an extended example with all available options.

@@ -111,8 +139,12 @@ jobs:
php-cs-fixer:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
@@ -169,7 +201,7 @@ You must use `action/checkout@v2` or later versions to check out the repository.
In non-`push` events, such as `pull_request`, make sure to specify the `ref` to check out:

```yaml
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
```
@@ -187,7 +219,7 @@ You can change this by creating a new [Personal Access Token (PAT)](https://gith
storing the token as a secret in your repository and then passing the new token to the [`actions/checkout`](https://github.com/actions/checkout#usage) Action step.

```yaml
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
```
@@ -198,17 +230,66 @@ If you work in an organization and don't want to create a PAT from your personal

### Change to file is not detected

Does your workflow change a file but "git-auto-commit" does not detect the change? Check the `.gitignore` that applies to the respective file. You might have accidentally marked the file to be ignored by git.
Does your workflow change a file, but "git-auto-commit" does not detect the change? Check the `.gitignore` that applies to the respective file. You might have accidentally marked the file to be ignored by git.

## Advanced Uses

### Multiline Commit Messages

If your commit message should span multiple lines, you have to create a separate step to generate the string.

The example below can be used as a starting point to generate a multiline commit meesage. Learn more how multiline strings in GitHub Actions work in the [GitHub documentation](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings).

```yaml
# Building a multiline commit message
# Adjust to your liking
- run: echo "Commit Message 1" >> commitmessage.txt
- run: echo "Commit Message 2" >> commitmessage.txt
- run: echo "Commit Message 3" >> commitmessage.txt
# Create a multiline string to be used by the git-auto-commit Action
- name: Set commit message
id: commit_message_step
run: |
echo 'commit_message<<EOF' >> $GITHUB_OUTPUT
cat commitmessage.txt >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
# Quick and dirty step to get rid of the temporary file holding the commit message
- run: rm -rf commitmessage.txt
- uses: stefanzweifel/git-auto-commit-action@v4
id: commit
with:
commit_message: ${{ steps.commit_message_step.outputs.commit_message }}
```

### Signing Commits & Other Git Command Line Options

Using command lines options needs to be done manually for each workflow which you require the option enabled. So for example signing commits requires you to import the gpg signature each and every time. The following list of actions are worth checking out if you need to automate these tasks regularly.

- [Import GPG Signature](https://github.com/crazy-max/ghaction-import-gpg) (Suggested by [TGTGamer](https://github.com/tgtgamer))

### Push to forks from private repositories

By default, GitHub Actions doesn't run Workflows on forks from private repositories. To enable Actions for **private** repositories enable "Run workflows from pull requests" in your repository settings.

See [this announcement from GitHub](https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/) or the [GitHub docs](https://docs.github.com/en/github/administering-a-repository/disabling-or-limiting-github-actions-for-a-repository#enabling-workflows-for-private-repository-forks) for details.


### Use in forks from public repositories

<details>
<summary>Use in forks from public repositories</summary>
<summary>Expand to learn more</summary>

**☝️ Important Notice**: This Action technically works with forks. However, please note that the combination of triggers and their options can cause issues. Please read [the documentation](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows) on which triggers GitHub Actions support.\
If you use this Action in combination with a linter/fixer, it's easier if you run the Action on `push` on your `main`-branch.
> **Note**
> This Action technically works with forks. However, please note that the combination of triggers and their options can cause issues. Please read [the documentation](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows) on which triggers GitHub Actions support.\
> Ensure your contributors enable "Allow edits by maintainers" when opening a pull request. ([Learn more](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)) \
> \
> **If you use this Action in combination with a linter/fixer, it's easier if you run the Action on `push` on your `main`-branch.**

---
> **Warning**
> Due to limitations of GitHub, this Action currently can't push commits to a base repository, if the fork _lives_ under an organisation. See [github/community#6634](https://github.com/orgs/community/discussions/5634) and [this comment](https://github.com/stefanzweifel/git-auto-commit-action/issues/211#issuecomment-1428849944) for details.

By default, this Action will not run on Pull Requests which have been opened by forks. (This is a limitation by GitHub, not by us.)
However, there are a couple of ways to use this Actions in Workflows that should be triggered by forked repositories.
@@ -234,10 +315,19 @@ on:
jobs:
php-cs-fixer:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Checkout the fork/head-repository and push changes to the fork.
# If you skip this, the base repository will be checked out and changes
# will be committed to the base repository!
repository: ${{ github.event.pull_request.head.repo.full_name }}
# Checkout the branch made in the fork. Will automatically push changes
# back to this branch.
ref: ${{ github.head_ref }}
- name: Run php-cs-fixer
@@ -248,6 +338,11 @@ jobs:

### Workflow should run in **forked** repository

> **Warning**
> **This part of the documentation is outdated.**
> We were not able to configure a GitHub Action workflow for forks, that the workflow would run in the fork / head repository.
> Please let us know in the [discussions](https://github.com/stefanzweifel/git-auto-commit-action/discussions)-area, if and how you achieved that.

If the workflow should run in the forked repository, follow these steps:

1. In addition to listening to the `pull_request` event in your Workflow triggers, you have to add an additional event: `pull_request_target`. You can learn more about this event in [the GitHub docs](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target).
@@ -271,7 +366,7 @@ jobs:
php-cs-fixer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run php-cs-fixer
uses: docker://oskarstark/php-cs-fixer-ga
@@ -295,37 +390,15 @@ For more information about running Actions on forks, see [this announcement from

</details>

<details>
<summary>Push to forks from private repositories</summary>

By default, GitHub Actions doesn't run Workflows on forks from private repositories. To enable Actions for **private** repositories enable "Run workflows from pull requests" in your repository settings.

See [this announcement from GitHub](https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/) or the [GitHub docs](https://docs.github.com/en/github/administering-a-repository/disabling-or-limiting-github-actions-for-a-repository#enabling-workflows-for-private-repository-forks) for details.

</details>

<details>
<summary>
Signing Commits & Other Git Command Line Options
</summary>

Using command lines options needs to be done manually for each workflow which you require the option enabled. So for example signing commits requires you to import the gpg signature each and every time. The following list of actions are worth checking out if you need to automate these tasks regularly.

- [Import GPG Signature](https://github.com/crazy-max/ghaction-import-gpg) (Suggested by [TGTGamer](https://github.com/tgtgamer))

</details>
### Using `--amend` and `--no-edit` as commit options

<details>
<summary>
Using `--amend` and `--no-edit` as commit options
</summary>



<summary>Expand to learn more</summary>

If you would like to use this Action to create a commit using [`--amend`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend) and [`--no-edit`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---no-edit) you need to make some adjustments.

**☝️ Important Notice:** You should understand the implications of rewriting history if you amend a commit that has already been published. [See rebasing](https://git-scm.com/docs/git-rebase#_recovering_from_upstream_rebase)
> **Warning**
> You should understand the implications of rewriting history if you amend a commit that has already been published. [See rebasing](https://git-scm.com/docs/git-rebase#_recovering_from_upstream_rebase).

First, you need to extract the previous commit message by using `git log -1 --pretty=%s`.
Then you need to provide this last commit message to the Action through the `commit_message` input option.
@@ -335,7 +408,7 @@ Finally, you have to use `push_options: '--force'` to overwrite the git history
The steps in your workflow might look like this:

```yaml
- uses: actions/checkout@master
- uses: actions/checkout@4
with:
# Fetch the last 2 commits instead of just 1. (Fetching just 1 commit would overwrite the whole history)
fetch-depth: 2
@@ -379,13 +452,14 @@ First, you have to create a new [Personal Access Token (PAT)](https://github.com
store the token as a secret in your repository and pass the new token to the [`actions/checkout`](https://github.com/actions/checkout#usage) Action step.

```yaml
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
```
You can learn more about Personal Access Token in the [GitHub documentation](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token).

**Note:** If you're working in an organisation, and you don't want to create the PAT from your personal account, we recommend using a bot-account for such tokens.
> **Note**
> If you're working in an organisation, and you don't want to create the PAT from your personal account, we recommend using a bot-account for such tokens.


If you go the "force pushes" route, you have to enable force pushes to a protected branch (See [documentation](https://help.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)) and update your Workflow to use force push like this.
Loading