Compare commits

..
258 Commits
Author SHA1 Message Date
Stefan Zweifel 4a55954c78 Update README.md 2026-06-28 10:54:21 +02:00
Stefan ZweifelandGitHub 9f6c933320 Add hooks to run shell snippets around git operations (#411)
* feat: add _run_hook helper and eight hook inputs

* fix(_run_hook): default snippet to empty when arg unset

* feat: wire add/commit hooks into _main

* feat: wire tag and push hooks into _main

* test: verify failing hook aborts the action

* docs: document hooks system in README

* test: tighten failing-hook assertion

* docs(hooks): note set -eu semantics for snippet authors

* refactor(hooks): rename action inputs to suffix with _hook

* refactor(hooks): include _hook suffix in event identifier

* docs(hooks): add notes about security implications of hooks
2026-06-28 10:52:27 +02:00
Stefan ZweifelandGitHub c365a749b4 Emit warning for pull_request_target trigger usage (#410)
* Emit warning when used with pull_request_target trigger
2026-06-27 14:33:12 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
d28176c21f Bump actions/checkout from 6 to 7 (#409)
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  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>
2026-06-24 14:20:43 +02:00
Stefan Zweifel 25df622d80 Add EXAMPLES.md 2026-06-08 07:01:57 +02:00
32e9844812 docs(action): fix input and output descriptions in action.yml (#406)
* docs(action): fix input and output descriptions in action.yml

* Update Wording

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Kranthi Poturaju <Kranthi.Poturaju1@aexp.com>
Co-authored-by: Stefan Zweifel <stefanzweifel@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-07 14:09:06 +02:00
a3ed46f7fd docs: fix typos, grammar, and formatting across markdown files (#408)
Co-authored-by: Kranthi Poturaju <Kranthi.Poturaju1@aexp.com>
Co-authored-by: Stefan Zweifel <stefanzweifel@users.noreply.github.com>
2026-05-07 13:38:18 +02:00
b4d688c224 docs: fix broken and redirecting URLs in README.md (#407)
Co-authored-by: Kranthi Poturaju <Kranthi.Poturaju1@aexp.com>
2026-05-07 13:32:29 +02:00
M.Sz.andGitHub f53a62c26e README: clearify meaning of the repository field (#404) 2026-03-22 17:30:45 +01:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
4fc4bbf34c Bump release-drafter/release-drafter from 6 to 7 (#403)
Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from 6 to 7.
- [Release notes](https://github.com/release-drafter/release-drafter/releases)
- [Commits](https://github.com/release-drafter/release-drafter/compare/v6...v7)

---
updated-dependencies:
- dependency-name: release-drafter/release-drafter
  dependency-version: '7'
  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>
2026-03-16 08:20:57 +01:00
Stefan Zweifel fc84150d7c Add alternative actions 2026-01-19 19:44:34 +01:00
Stefan Zweifel df21a760dd Remove Security Link from config.yml 2026-01-17 08:25:12 +01:00
Stefan Zweifel e4b712e8e8 Add Security Policy 2026-01-17 08:24:22 +01:00
Stefan Zweifel 6739571eae Add Note about persist-credentials to README 2026-01-03 08:53:26 +01:00
stefanzweifelandgithub-actions[bot] b811de3f2d Update CHANGELOG 2025-12-17 19:26:02 +00:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
04702edda4 Bump actions/checkout from 5 to 6 (#399)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-17 20:23:57 +01:00
1e49d5001f Add skip_push input option (#401)
Co-authored-by: Stefan Zweifel <stefan@stefanzweifel.dev>
2025-12-17 20:23:26 +01:00
GideonandGitHub 65c56779c9 docs: fix typo in README.md (#400) 2025-12-03 12:10:40 +01:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
547c1409ce Bump bats from 1.12.0 to 1.13.0 (#398)
Bumps [bats](https://github.com/bats-core/bats-core) from 1.12.0 to 1.13.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](https://github.com/bats-core/bats-core/compare/v1.12.0...v1.13.0)

---
updated-dependencies:
- dependency-name: bats
  dependency-version: 1.13.0
  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>
2025-11-10 08:08:12 +01:00
stefanzweifelandgithub-actions[bot] 8fa7f5a3c5 Update CHANGELOG 2025-10-12 14:39:35 +00:00
Stefan ZweifelandGitHub 28e16e8177 Release preparations for v7 (#394) 2025-10-12 16:31:03 +02:00
Stefan ZweifelandGitHub 698fd76863 Merge pull request #391 from EliasBoulharts/custom-tag-message 2025-10-12 15:13:29 +02:00
Stefan Zweifel c40819ab3b Update README 2025-10-12 14:59:32 +02:00
Stefan Zweifel d7ee275235 Change internal variable names 2025-10-12 14:37:32 +02:00
Stefan Zweifel e8684eb0cd Fix Tests 2025-10-12 14:27:10 +02:00
Stefan Zweifel 19497011bb Merge branch 'master' into pr/391 2025-10-12 14:11:57 +02:00
Stefan ZweifelandGitHub a88dc49508 Merge pull request #388 from stefanzweifel/v7-next 2025-10-12 14:02:15 +02:00
Stefan ZweifelandGitHub a531deca6b Merge pull request #386 from stefanzweifel/dependabot/github_actions/actions/checkout-5 2025-10-12 13:40:50 +02:00
Stefan ZweifelandGitHub acbe8b15bf Merge pull request #393 from stefanzweifel/v7-warn-detached-head 2025-09-30 16:54:18 +02:00
Stefan Zweifel d1854850ec Enable Detached State Check 2025-09-30 16:48:49 +02:00
Elias Boulharts e9f84b936b feature: allow using custom tag message
Signed-off-by: Elias Boulharts <elias@MacBook-Pro-de-Elias.local>
2025-09-24 12:15:10 +02:00
Stefan ZweifelandGitHub d2e5cae4c6 Merge pull request #389 from stefanzweifel/v7-node-24
Run Action on Node 24
2025-09-22 07:20:05 +02:00
Stefan Zweifel 858005f1b9 Switch to Node24 2025-09-22 07:11:49 +02:00
Stefan Zweifel 9a4902607d Update Tests 2025-09-17 14:08:26 +02:00
Stefan Zweifel d330c718ba Remove warnings of deprecated inputs 2025-09-17 13:32:46 +02:00
Stefan Zweifel 5fe35a088d Restore Tests 2025-09-17 11:48:35 +02:00
Stefan Zweifel 2da8d963b4 Restore skip_fetch, skip_checkout, create_branch 2025-09-17 11:02:55 +02:00
dependabot[bot]andGitHub 7ddc571aec Bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-18 08:56:44 +00:00
Stefan ZweifelandGitHub 01d77ca6cb Merge pull request #382 from stefanzweifel/dependabot/github_actions/stefanzweifel/git-auto-commit-action-6 2025-06-16 09:45:04 +02:00
dependabot[bot]andGitHub 6371fedd09 Bump stefanzweifel/git-auto-commit-action from 5 to 6
Bumps [stefanzweifel/git-auto-commit-action](https://github.com/stefanzweifel/git-auto-commit-action) from 5 to 6.
- [Release notes](https://github.com/stefanzweifel/git-auto-commit-action/releases)
- [Changelog](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5...v6)

---
updated-dependencies:
- dependency-name: stefanzweifel/git-auto-commit-action
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-16 06:39:19 +00:00
Stefan Zweifel f9017b24ee Update README to use v6 in examples 2025-06-13 16:47:49 +02:00
stefanzweifelandgithub-actions[bot] 66f124b8c2 Update CHANGELOG 2025-06-11 11:27:36 +00:00
Stefan ZweifelandGitHub 778341af66 Merge pull request #379 from stefanzweifel/disable-detached-state-check 2025-06-11 13:26:39 +02:00
Stefan Zweifel 33b203d92a Disable Check if Repo is in Detached State
Fixes #378
2025-06-11 13:22:17 +02:00
stefanzweifelandgithub-actions[bot] a82d80a75f Update CHANGELOG 2025-06-10 18:44:47 +00:00
Stefan ZweifelandGitHub 3cc016cfc8 Merge pull request #375 from stefanzweifel/v6-next 2025-06-10 20:19:14 +02:00
Stefan ZweifelandGitHub ddb7ae4159 Merge pull request #376 from Dreamsorcerer/patch-1 2025-06-02 21:38:08 +02:00
Stefan ZweifelandGitHub b001e5f0ff Apply suggestions from code review 2025-06-02 21:37:45 +02:00
Sam BullandGitHub 6494dc61d3 Fix PAT instructions with Dependabot 2025-05-28 15:08:30 +01:00
Stefan Zweifel 76180511d9 Add deprecated inputs to fix unbound variable issue 2025-05-28 11:37:04 +02:00
Stefan ZweifelandGitHub ae114628ea Merge pull request #371 from stefanzweifel/dependabot/npm_and_yarn/bats-1.12.0 2025-05-19 09:43:11 +02:00
dependabot[bot]andGitHub 3058f91afb Bump bats from 1.11.1 to 1.12.0
Bumps [bats](https://github.com/bats-core/bats-core) from 1.11.1 to 1.12.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](https://github.com/bats-core/bats-core/compare/v1.11.1...v1.12.0)

---
updated-dependencies:
- dependency-name: bats
  dependency-version: 1.12.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-19 06:08:17 +00:00
Stefan Zweifel 8ddf02de71 Add git-auto-commit to warning text 2025-05-03 16:03:43 +02:00
Stefan Zweifel e7955f713c Emit warning if deprecated/removed options are used 2025-05-03 15:51:01 +02:00
Stefan Zweifel 739fd03b2d Merge branch 'master' into v6-next 2025-05-03 10:31:03 +02:00
stefanzweifelandgithub-actions[bot] af302a9c63 Update CHANGELOG 2025-04-19 08:40:01 +00:00
Stefan ZweifelandGitHub b863ae1933 Merge pull request #367 from stefanzweifel/stefanzweifel/git_tag_only_changes
Add Test for create_git_tag_only feature
2025-04-19 10:33:31 +02:00
Stefan Zweifel adb37b5a29 Update README 2025-04-19 10:32:21 +02:00
Stefan Zweifel 8480c68cbb Add Tests 2025-04-19 10:23:52 +02:00
Stefan Zweifel 4f8f3ad16e Rename Input and add output 2025-04-19 10:23:52 +02:00
Stefan ZweifelandGitHub 11a6e5f38f Merge pull request #364 from zmynx/master
feat: allow for clean tag pushing
2025-04-19 10:23:02 +02:00
Lior DuxandGitHub 35d037abf5 Update README.md 2025-03-23 22:33:45 +02:00
Lior DuxandGitHub bf425dc136 Merge branch 'master' into master 2025-03-23 22:32:20 +02:00
Lior DuxandGitHub cfd6ac4a3b Update git-auto-commit.bats 2025-03-23 22:14:41 +02:00
Lior DuxandGitHub 19379b46c9 Update git-auto-commit.bats 2025-03-23 22:05:21 +02:00
Lior DuxandGitHub 12e100dacb Update entrypoint.sh 2025-03-23 22:05:01 +02:00
Lior DuxandGitHub 2ac10431a8 Update action.yml 2025-03-23 22:02:49 +02:00
Lior DuxandGitHub 4db797a961 Update entrypoint.sh 2025-03-23 22:01:31 +02:00
Stefan ZweifelandGitHub e256565ae5 Merge pull request #361 from rasa/patch-1
docs: Update README.md per #354
2025-03-13 20:29:15 +01:00
Ross Smith IIandGitHub 8a23be4b32 docs: Update README.md per #354
See #354
2025-03-13 08:29:02 -07:00
Stefan ZweifelandGitHub ed295bd35a Merge pull request #357 from stefanzweifel/v6-detect-detached-state 2025-02-05 18:00:42 +01:00
Stefan Zweifel bd434eed48 Use ref checkout properly 2025-02-05 17:34:26 +01:00
Stefan Zweifel 1666a49083 Use ref in auto-commit workflow 2025-02-05 17:27:23 +01:00
Stefan Zweifel 1d986f74dd Improve Error Message 2025-02-05 17:17:19 +01:00
Stefan Zweifel ad56d4eb46 Throw error if repo is in detached state 2025-02-05 17:14:02 +01:00
Stefan ZweifelandGitHub 9fa4cb99cf Merge pull request #314 from stefanzweifel/v6/remove-local-branch-switch 2025-02-05 16:01:10 +01:00
Stefan Zweifel cec27bde37 Fix Typo 2025-02-05 15:59:51 +01:00
Stefan Zweifel 244febd79d Add UPGRADING.md 2025-02-05 15:57:55 +01:00
Stefan Zweifel c86fa26bed Replace Yarn with NPM 2025-02-05 13:54:04 +01:00
stefanzweifelandgithub-actions[bot] e35726034b Update CHANGELOG 2025-01-11 07:12:19 +00:00
Stefan ZweifelandGitHub e348103e90 Merge pull request #354 from parkerbxyz/patch-1 2025-01-11 08:10:58 +01:00
Parker BrownandGitHub 032ffbefae Include github.actor_id in default commit_author
This mimics the default commit author used by GitHub and matches the format used for the default `commit_user_email`.
2025-01-10 15:38:54 -08:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
0b492c0d95 Bump bats from 1.11.0 to 1.11.1 (#353)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-02 08:06:23 +01:00
Stefan Zweifel 050015d406 Add Scope/Permissions documentation for PATs
Closes #347
2024-10-06 10:39:09 +02:00
scarfandGitHub 573710f3d0 docs(README): fix broken protected branch docs link (#346) 2024-10-04 08:56:00 +02:00
Marcelo TrylesinskiandGitHub e961da7576 Update README.md (#343) 2024-09-22 16:50:21 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
ac8823709a Bump github/super-linter from 6 to 7 (#342)
Bumps [github/super-linter](https://github.com/github/super-linter) from 6 to 7.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/super-linter/compare/v6...v7)

---
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>
2024-09-02 08:16:51 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
be823a7e51 Bump github/super-linter from 5 to 6 (#335)
Bumps [github/super-linter](https://github.com/github/super-linter) from 5 to 6.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/super-linter/compare/v5...v6)

---
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>
2024-07-08 08:26:25 +02:00
Stefan Zweifel 55a82ca24f Add Section on preventing infinite loops to README 2024-07-06 15:14:44 +02:00
Stefan Zweifel 18157e6f3b Update bug.yaml 2024-07-06 12:07:25 +02:00
Stefan Zweifel 7d779d0067 Update Bug Repo Form 2024-07-06 12:06:47 +02:00
Stefan Zweifel efd424db0f Fix link to "new feature request" 2024-07-06 12:00:09 +02:00
Stefan Zweifel 5f3fa8aed3 Add docs about .github/workflows pushes
See #322
2024-07-06 11:43:22 +02:00
Stefan Zweifel ee5525316d Update GPG Signing section in README 2024-07-02 20:41:34 +02:00
Stefan Zweifel 4b8a201e31 Add with ref github.head_ref to README 2024-04-13 10:35:11 +02:00
stefanzweifelandgithub-actions[bot] 896cc0d225 Update CHANGELOG 2024-04-12 06:47:58 +00:00
8621497c8c Fail if attempting to execute git commands in a directory that is not a git-repo. (#326)
* Fail (and log message) if attempting to execute git commands in a directory that is not a git-repo.

* Add Test

* Code Formatting

---------

Co-authored-by: Constantin Comendant <constantin@uberagent.com>
Co-authored-by: Stefan Zweifel <stefan@stefanzweifel.dev>
2024-04-11 21:00:36 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
b0f4d47f59 Bump bats from 1.10.0 to 1.11.0 (#325)
Bumps [bats](https://github.com/bats-core/bats-core) from 1.10.0 to 1.11.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](https://github.com/bats-core/bats-core/compare/v1.10.0...v1.11.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>
2024-03-26 08:29:07 +01:00
Christian VermeulenandGitHub 9b5e5ee10a Add step id explanation for output in README.md (#324) 2024-03-15 16:06:58 +01:00
Philip CoulingandGitHub e040c596f0 Linux is not UNIX (#321) 2024-02-22 08:26:06 +01:00
dependabot[bot]andGitHub 4d160c5e4d Bump release-drafter/release-drafter from 5 to 6 (#319) 2024-02-06 07:16:57 +01:00
12f68633e4 Clarify commit_author input option (#315)
* Clarify `commit_author` input option

* Update README.md

---------

Co-authored-by: Stefan Zweifel <stefanzweifel@users.noreply.github.com>
2023-12-24 07:35:30 +01:00
Stefan Zweifel 7f171889c8 Remove removed options from README 2023-12-20 20:20:24 +01:00
Stefan Zweifel 76f415fb30 Remove skip_fetch, skip_checkout and create_branch 2023-12-20 20:19:38 +01:00
Stefan Zweifel 3e796a0146 Update Assertion 2023-12-20 20:13:20 +01:00
Stefan Zweifel e833d4f211 Remove _switch_to_branch function 2023-12-20 20:10:12 +01:00
Stefan Zweifel 0aca01a1ef Remove no longer used input options from tests 2023-12-20 20:09:59 +01:00
Stefan Zweifel 03fddc470c Temp disable assertions 2023-12-20 20:09:40 +01:00
Stefan Zweifel ef7ed32535 Remove no longer needed tests 2023-12-20 20:03:21 +01:00
Stefan Zweifel 9062db8404 Update Tests 2023-12-19 21:00:32 +01:00
Stefan Zweifel 80052f0645 Update Tests 2023-12-19 20:45:55 +01:00
Stefan Zweifel 3b8231379d Update Tests 2023-12-19 20:34:56 +01:00
Stefan Zweifel d9307b5e8c Update Test 2023-12-19 20:13:01 +01:00
Stefan Zweifel aa2cec9c08 Don't switch local branches 2023-12-19 20:11:39 +01:00
Stefan Zweifel 29183a25ec Remove outdated docs 2023-12-12 20:45:33 +01:00
Stefan Zweifel 2818fe7949 Add Alert about pull_request_target
https://github.com/stefanzweifel/git-auto-commit-action/issues/211#issuecomment-1837270114
2023-12-12 20:42:25 +01:00
Stefan Zweifel 8d90676eef Little Doc Updates 2023-12-12 20:38:26 +01:00
Stefan Zweifel 8036286d37 Use new Markdown Alerts in README 2023-12-12 20:38:06 +01:00
Stefan Zweifel e8f94e4dd2 Merge branch 'master' of github.com:stefanzweifel/git-auto-commit-action 2023-10-06 19:56:36 +02:00
Stefan Zweifel 98d2782f49 Use v5 in README 2023-10-06 19:56:33 +02:00
Stefan Zweifel eb38c210f2 Use v5 in update-changelog Workflow 2023-10-06 19:56:27 +02:00
stefanzweifelandgithub-actions[bot] e27a68931b Update CHANGELOG 2023-10-06 17:55:19 +00:00
高井GitHubryudai.takai
8756aa072e Update node version to node20 (#300)
Co-authored-by: ryudai.takai
2023-10-06 19:43:01 +02:00
Stefan Zweifel 17a44b07bf Merge branch 'master' of github.com:stefanzweifel/git-auto-commit-action 2023-10-06 19:31:58 +02:00
Stefan Zweifel 43818d5044 Fix Typo 2023-10-06 19:30:48 +02:00
Stefan ZweifelandGitHub 10944650cd Use actions/checkout v4 in examples
https://github.com/stefanzweifel/git-auto-commit-action/pull/302#issuecomment-1745974288
2023-10-04 15:33:04 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3d1b5e078a 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](https://github.com/actions/checkout/compare/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>
2023-09-11 10:32:33 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
47a8ad5f38 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](https://github.com/bats-core/bats-core/compare/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>
2023-07-17 09:56:06 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
77a7b3fb3c 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](https://github.com/github/super-linter/compare/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>
2023-06-23 09:20:59 +02:00
Pedro Amador RodríguezandGitHub 9cc0a1f55d Seems like there is an extra space (#288) 2023-04-03 08:55:34 +02:00
Stefan Zweifel 0b5f8a5333 Update Test 2023-03-28 14:46:47 +02:00
Stefan Zweifel 3a446b74f0 Merge branch 'master' of github.com:stefanzweifel/git-auto-commit-action 2023-02-15 19:45:07 +01:00
Stefan Zweifel 8e108d701f 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 https://github.com/stefanzweifel/git-auto-commit-action/issues/211#issuecomment-1428849944 for more details.
2023-02-15 19:44:45 +01:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
c8254de74f 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](https://github.com/bats-core/bats-core/compare/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>
2023-02-13 08:22:21 +01:00
Stefan Zweifel 6436584fbb Fix Comment in README 2023-02-11 21:31:27 +01:00
Stefan Zweifel 6656e54255 Use actions/checkout@v3 in examples 2023-02-11 21:29:21 +01:00
Stefan Zweifel f0b35f0a73 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/
2023-02-11 21:29:07 +01:00
Stefan Zweifel ccd4d054a5 Fix Typo in Workflow comments 2023-02-11 21:14:56 +01:00
Stefan Zweifel 94d6bf9d22 Add permissions block to Workflows 2023-02-11 12:23:24 +01:00
Stefan Zweifel f44d1cd002 Merge branch 'master' of github.com:stefanzweifel/git-auto-commit-action 2023-01-25 19:58:10 +01:00
Stefan Zweifel 92b3981e0b Update Author Email Address 2023-01-25 19:57:43 +01:00
Stefan ZweifelandGitHub 3b94e3d017 Update README.md
Closes #281
2023-01-20 15:31:53 +01:00
Stefan ZweifelandGitHub 3663a6fa3e Update README.md 2023-01-14 18:05:16 +01:00
Stefan Zweifel fe00d25867 Add test for multi-line commit messages 2023-01-07 12:06:10 +01:00
congandGitHub 86fb2e11b2 Fix git-auto-commit.yml (#277) 2023-01-03 08:17:32 +01:00
Stefan ZweifelandGitHub aeb1802648 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
2022-12-22 19:45:17 +01:00
stefanzweifelandgithub-actions[bot] 925bbcaef3 Update CHANGELOG 2022-12-02 06:50:39 +00:00
3ea6ae190b Fix "nothing to commit" error with LF/CRLF changes #241 (#265)
* fix crlf test

* add diff check before commit

* add dirty check flag (not sure if needed)

* Update test name and add more assertions

Update test name to make it clear that the Action no longer fails to detect CRLF changes.

* Add Comment to explain why we use git-diff again

* Add test to confirm content changes are commited

* Closes #241 

Co-authored-by: Stefan Zweifel <hello@stefanzweifel.io>
2022-12-01 20:47:06 +01:00
TekoandGitHub 976f22029f Fix github-actions[bot] email address (#264) 2022-11-15 20:12:31 +01:00
TekoandGitHub ebb5756042 Fix link and text for workflow limitation (#263) 2022-11-13 10:06:41 +01:00
stefanzweifelandgithub-actions[bot] 3dce995a13 Update CHANGELOG 2022-11-05 10:56:08 +00:00
Stefan ZweifelandGitHub 0b007fbd11 Let Action fail if git binary can't be located (#261)
* Check if git binary exists

* Add Tests
2022-11-05 11:53:46 +01:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
7106b2184a Bump github/super-linter from 3 to 4 (#258)
Bumps [github/super-linter](https://github.com/github/super-linter) from 3 to 4.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v3...v4)

---
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>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-26 19:05:48 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
f166130208 Bump bats from 1.7.0 to 1.8.2 (#259)
Bumps [bats](https://github.com/bats-core/bats-core) from 1.7.0 to 1.8.2.
- [Release notes](https://github.com/bats-core/bats-core/releases)
- [Changelog](https://github.com/bats-core/bats-core/blob/master/docs/CHANGELOG.md)
- [Commits](https://github.com/bats-core/bats-core/compare/v1.7.0...v1.8.2)

---
updated-dependencies:
- dependency-name: bats
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-26 19:04:33 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
021a6363fa Bump actions/checkout from 2 to 3 (#257)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-26 19:03:57 +02:00
Stefan ZweifelandGitHub 38864a638f Create dependabot.yml 2022-10-26 19:02:41 +02:00
stefanzweifelandgithub-actions[bot] 393fea59ef Update CHANGELOG 2022-10-26 16:57:18 +00:00
Stefan ZweifelandGitHub 0049e3fa40 Use deprecated set-output syntax if GITHUB_OUTPUT environment is not available (#255)
* Fallback to set-output if GITHUB_OUTPUT not available

* Add Tests to cover old syntax
2022-10-26 18:55:42 +02:00
stefanzweifelandgithub-actions[bot] f6f7a9c351 Update CHANGELOG 2022-10-22 09:19:59 +00:00
Andrew MonshizadehandGitHub 2fde6fc18d Replace set-output usage with GITHUB_OUTPUT (#252)
* GitHub has deprecated set-output and now needs to add the content to the GITHUB_OUTPUT file

* Update tests too

* Fix tests and shell-format changes

* Revert yarn.lock changes
2022-10-22 10:42:11 +02:00
Stefan ZweifelandGitHub faf78595b8 Update README.md 2022-10-21 09:28:08 +02:00
stefanzweifelandgithub-actions[bot] a0873a0795 Update CHANGELOG 2022-10-10 17:17:41 +00:00
Stefan ZweifelandGitHub fd157da78f Run Action on Node16 (#247)
closes #246
2022-10-10 19:15:24 +02:00
Stefan Zweifel b208f78c10 Test that CRLF changes are not picked up
This PR adds a test to confirm, that changes to CRLF are not properly detected and that the message "Working tree clean. Nothing to commit." is displayed.

Setting `core.autocrlf` to `true` also has no effect here.

refs #241
2022-09-28 20:19:50 +02:00
stefanzweifelandgithub-actions[bot] cef08f2918 Update CHANGELOG 2022-09-24 08:53:51 +00:00
Stefan Zweifel 6c32682a40 Add bug label to new issues 2022-09-17 16:37:41 +02:00
Stefan Zweifel a4a482b6c5 Update Issue Templates 2022-09-17 16:35:49 +02:00
Stefan Zweifel 18870f2286 Add note about line break detection 2022-09-17 16:02:44 +02:00
Stefan Zweifel 52eb0eedc8 Update README 2022-09-17 15:34:02 +02:00
03246c1cee Changed the extended example to correctly use quotes for strings (#196)
Co-authored-by: Stefan Zweifel <stefanzweifel@users.noreply.github.com>
2022-09-17 15:33:25 +02:00
Stefan ZweifelandGitHub 4d00f10668 Expand file_pattern-input to an array (#205)
* Expand file_pattern input

* Expand file pattern array in git-status

* Add Failing Test

* Expand INPUT_FILE_PATTERN

* Fix Shellcheck Issues

* Add test to cover file expansion works when globbing is disabled

* Add explanation to README
2022-09-17 15:18:36 +02:00
Stefan Zweifel 4e7c0d67cd Assert throws error when force adding ignored files
See https://github.com/stefanzweifel/git-auto-commit-action/issues/204#issuecomment-1236880360
2022-09-06 21:04:34 +02:00
Stefan Zweifel dce7e85096 Add Tests to Cover #233 2022-07-30 20:21:57 +02:00
Stefan Zweifel 9262405709 Fix Typo in Test 2022-07-30 20:14:41 +02:00
Stefan Zweifel 32807d4f18 Upgrade Bats 2022-07-30 20:14:29 +02:00
Derrick LeeandGitHub f5b5fefa06 docs: fix typos and grammer errors in readme.md (#235) 2022-07-27 08:23:35 +02:00
MarcoandGitHub f33e764001 fix typo in readme (#230)
remote was misspelled
2022-07-11 15:25:38 +02:00
Stefan Zweifel f0d72a04e7 Add note about pathspec error 2022-06-29 20:24:50 +02:00
Stefan Zweifel 571d6b78ed Add test to verify issue #227
This test confirms the problem mentioned in #227.

If `file_pattern` contains a pattern of, for example 2 file extensions, and only files for one extensions are dirty but not for the otherone, `git-add` will throw a fatal error.

It does not throw an error if the files for the pattern already exist but are not dirty.
2022-06-28 20:08:10 +02:00
Stefan Zweifel f990bd0ed1 Add Note about .gitignore 2022-06-27 20:56:36 +02:00
789f58e41a Add missing links in the CHANGELOG (#223)
* Update CHANGELOG

Add missing references to Pull Requests.

* Link to PRs and Authors in upcoming release notes

Co-authored-by: Stefan Zweifel <hello@stefanzweifel.io>
2022-06-06 07:36:31 +02:00
Stefan Zweifel 79ae6eea95 Update README concerning pull_request_target trigger
Closes #211
2022-04-15 20:06:11 +02:00
stefanzweifelandGitHub Actions 488db3d503 Update CHANGELOG 2022-04-12 18:43:36 +00:00
Stefan Zweifel 49620cd3ed Update README.md 2022-04-12 20:33:36 +02:00
Jonas LandGitHub 73f17337ef Use github-actions[bot] user as commit user (#213)
Fixes #212
2022-04-12 20:30:34 +02:00
GeoffandGitHub 30fd9f94bc Update README.md (#206) 2022-03-23 08:14:36 +01:00
Stefan ZweifelandGitHub d0487b9fa3 Update README.md 2022-03-19 07:46:33 +01:00
stefanzweifelandGitHub Actions 2719df73cd Update CHANGELOG 2022-03-18 19:29:58 +00:00
Stefan Zweifel c4b132ec2c Update file_pattern related test 2022-02-27 12:10:20 +01:00
Stefan Zweifel 19c7b84a3c Update README 2022-02-27 11:18:39 +01:00
Stefan ZweifelandGitHub ebe77391c6 Add create_branch option to force create a new branch (#203)
* Add create_branch option

* Checkout new branch if create_branch input is true

* Add tests

* Update README
2022-02-27 07:52:17 +01:00
Stefan Zweifel dee58f4213 Remove nbsp from entrypoint.sh 2022-02-22 20:02:04 +01:00
Stefan ZweifelandGitHub 248fbacc3e Add note about scopes for PAT 2022-01-24 16:51:53 +01:00
Stefan ZweifelandGitHub 2d5591a740 Merge pull request #200 from funkyfuture/patch-1 2022-01-24 16:31:37 +01:00
Frank SachsenheimandGitHub 22695fb19e README.md: Updates hyperlink to GH docs 2022-01-24 15:55:20 +01:00
stefanzweifelandGitHub Actions 8f6736864a Update CHANGELOG 2022-01-13 18:17:02 +00:00
Stefan ZweifelandGitHub 5804e42f86 Merge pull request #199 from kenodegard/disambiguate
Properly disambiguate between branch or file checkout
2022-01-12 21:08:17 +01:00
Stefan Zweifel e3cb9ba079 Add Test Case 2022-01-12 21:05:06 +01:00
Ken Odegard af49309116 Properly disambiguate between branch or file checkout 2022-01-11 10:21:56 -06:00
Stefan ZweifelandGitHub b244c38293 Update CHANGELOG.md 2022-01-10 20:28:24 +01:00
stefanzweifelandGitHub Actions c463ede7c3 Update CHANGELOG 2022-01-10 19:27:51 +00:00
Stefan ZweifelandGitHub 8040434425 Merge pull request #197 from cmbuckley/skip-checkout
Add `skip_checkout` option
2022-01-10 20:11:32 +01:00
Chris Buckley fc174e2406 Add skip_checkout option 2022-01-10 00:17:58 +00:00
Stefan ZweifelandGitHub 8c3ed373fb Merge pull request #180 from ericcornelissen/docs/permissions
Add note on minimum permissions to the docs
2021-10-04 08:19:11 +02:00
Eric Cornelissen 797544dbd2 Update README.md
Add note on minimum required permission.
2021-10-03 22:18:07 +02:00
Stefan Zweifel 0d6c97e470 Update README.md 2021-09-26 11:39:31 +02:00
Stefan Zweifel f6048aa2ac Add Test to Cover #177
refs #177
2021-09-25 16:06:43 +02:00
Stefan Zweifel 983386a337 Add update-changelog Workflow 2021-09-10 19:54:41 +02:00
Stefan Zweifel b8ff4cd716 Add release-drafter Workflow 2021-09-10 19:53:48 +02:00
Stefan Zweifel abd87b7d94 Release v4.12.0 2021-09-10 19:47:39 +02:00
Stefan Zweifel 54cc2186d1 Remove unwanted chars from tests 2021-09-10 19:47:01 +02:00
Stefan ZweifelandGitHub 216b25a401 Merge pull request #172 from webignition/issue-171
Output hash of created commit
2021-09-10 19:41:23 +02:00
Jon Cram 05aea7e2d9 Add commit_hash output description to readme 2021-09-10 14:37:45 +01:00
Jon Cram 68fd92dd9c Output hash of created commit 2021-09-10 14:37:45 +01:00
Stefan ZweifelandGitHub 0426839718 Merge pull request #173 from webignition/run-checks-on-pull-request
Run git-auto-commit, linter and tests checks on pull requests
2021-09-10 15:32:18 +02:00
Stefan ZweifelandGitHub 97badfaf41 Revert Linter to only run on push event 2021-09-10 15:31:37 +02:00
Jon Cram 10257e2994 Run git-auto-commit, linter and tests checks on pull requests 2021-09-10 13:49:19 +01:00
Stefan ZweifelandGitHub e107e28c4e Update README.md 2021-08-19 08:37:15 +02:00
Stefan ZweifelandGitHub 6834afe239 Update README.md 2021-08-18 20:49:52 +02:00
Stefan Zweifel 27ac2f0a7b Update README 2021-08-18 20:43:30 +02:00
Stefan ZweifelandGitHub 3568db7bbc Add note about bash dependency 2021-07-13 20:18:17 +02:00
Stefan Zweifel 053f356774 Improve amend section in README
refs #159
2021-05-22 11:34:55 +02:00
Stefan Zweifel 46af2f08b3 Add Example for —amend to README
refs #159
2021-05-20 20:30:05 +02:00
Stefan Zweifel 5dd17c3b53 Release v4.11.0 2021-05-03 21:01:59 +02:00
Stefan Zweifel ebbf8e517a Update README 2021-05-03 20:54:47 +02:00
Stefan Zweifel 76f1ae2f1a Add Credits to README 2021-05-03 20:23:02 +02:00
Stefan Zweifel b9c536534c Add new *_options to README 2021-05-03 20:22:53 +02:00
Stefan ZweifelandGitHub 68f0d95687 Merge pull request #156 from funkjedi/status-add-options
Add options for git add/status commands
2021-05-03 17:43:58 +02:00
Tim Robertson ccad85927e Add options for add/status commands 2021-05-03 11:26:56 -04:00
Stefan Zweifel 48d37c1ffb Tag v4.10.0 2021-04-12 21:04:42 +02:00
Stefan ZweifelandGitHub 4c05e3d58e Merge pull request #154 from stefanzweifel/fixes/153
Add "disable_globbing" option to prevent shell from expanding filenames
2021-04-12 20:54:39 +02:00
Stefan Zweifel 3053f48bdd Update Comments 2021-04-10 17:13:22 +02:00
Stefan Zweifel cfd366418e Update README 2021-04-10 17:11:30 +02:00
Stefan Zweifel be370eccae Create flag to disable globbing 2021-04-10 17:10:27 +02:00
Stefan Zweifel f4f9aedbee Set noglob in git-auto-commit 2021-04-10 16:58:48 +02:00
Stefan Zweifel e610a5104b Add failing test 2021-04-10 16:53:50 +02:00
Stefan Zweifel be7095c202 Release v4.9.2 2021-03-04 17:53:06 +01:00
Stefan Zweifel ae9ae1b5b8 Update Changelog 2021-03-02 20:21:56 +01:00
Stefan ZweifelandGitHub e944668910 Merge pull request #146 from stefanzweifel/fixes/145
Push Tags along with Commits
2021-03-02 20:20:29 +01:00
Stefan Zweifel 9bb0fd2324 Push tags by using —follow-tags and —atomic
By using —follow-tags we push all annotated tags alongside the commit to the remote repository.
In addition, we’re using —atomic. This ensures that all refs are updated.

- https://github.blog/2015-04-30-git-2-4-atomic-pushes-push-to-deploy-and-more/#atomic-pushes
- https://stackoverflow.com/a/3745250
- https://therightstuff.medium.com/the-rights-and-wrongs-of-git-push-with-tags-998667eaed8f
2021-02-26 20:17:32 +01:00
Stefan Zweifel 175c2cd836 Add failing tests 2021-02-26 19:44:37 +01:00
Stefan Zweifel 296e083b4c Tag v4.9.1 2021-02-23 21:18:33 +01:00
Stefan ZweifelandGitHub 871ade1c45 Merge pull request #144 from stefanzweifel/revert-140-feature/create-new-branch-during-checkout
Revert "Feature: Create a new branch, if the given branch name doesn't exist yet"
2021-02-23 21:16:57 +01:00
Stefan ZweifelandGitHub 75625df4f3 Revert "Feature: Create a new branch, if the given branch name doesn't exist yet" 2021-02-23 21:14:19 +01:00
Stefan Zweifel 3870982ac5 Improve Names of test repo folders 2021-02-23 20:08:01 +01:00
Stefan Zweifel 268ec0c240 Release v4.9.0 2021-02-20 20:34:30 +01:00
Stefan ZweifelandGitHub 9abc4c41e5 Merge pull request #140 from stefanzweifel/feature/create-new-branch-during-checkout
Feature: Create a new branch, if the given branch name doesn't exist yet
2021-02-20 20:29:23 +01:00
Stefan Zweifel 1aee6e6b46 Make Linter Happy 2021-02-07 16:14:11 +01:00
Stefan Zweifel 94941cff88 Cleanup Code 2021-02-07 16:09:59 +01:00
Stefan Zweifel 7507738fca Use git branch --list 2021-02-07 16:07:43 +01:00
Stefan Zweifel 53438d58ce Create new branch if NAME is given 2021-02-07 15:44:48 +01:00
Stefan Zweifel 8056699617 Add Testcase 2021-02-07 15:44:12 +01:00
Stefan Zweifel 520c63c171 Add Link to Article 2021-02-06 19:11:12 +01:00
Stefan ZweifelandGitHub a6006229e0 Merge pull request #138 from stefanzweifel/test-rm-is-tracked
Add Test to verify that removed files are picked up by the Action
2021-01-18 20:34:44 +01:00
Stefan Zweifel 40b55695d1 Add Test 2021-01-18 20:31:50 +01:00
Stefan ZweifelandGitHub 8f33b6cc31 Merge pull request #136 from palmerabollo/patch-1
docs: minor typo
2021-01-15 15:21:34 +01:00
Guido GarcíaandGitHub c4ab3ecb7e docs: minor typo 2021-01-15 15:19:06 +01:00
Stefan ZweifelandGitHub 350754fe3a Update LICENSE 2021-01-08 17:31:07 +01:00
25 changed files with 3370 additions and 308 deletions
+69
View File
@@ -0,0 +1,69 @@
name: Bug Report
description: If you've already asked for help with a problem and confirmed something is broken with git-auto-commit itself, create a bug report.
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Before opening a bug report, please search for the behaviour in existing issues or discussions.
---
Thank you for taking the time to file a bug report!
- type: input
id: git-auto-commit-version
attributes:
label: git-auto-commit Version
description: "Which exact version of git-auto-commit are you using in your Workflow?"
placeholder: "v4.14.0"
validations:
required: true
- type: dropdown
id: machine
attributes:
label: Machine Type
description: On which type of machine is your workflow running?
options:
- Ubuntu (eg. ubuntu-latest)
- macOS (eg. macos-latest)
- Windows (Not supported!)
validations:
required: true
- type: textarea
id: bug-description
attributes:
label: Bug description
description: What exactly happened? Please describe your problem in detail.
validations:
required: true
- type: textarea
id: steps
attributes:
label: Steps to reproduce
description: Which steps do we need to take to reproduce this error?
validations:
required: true
- type: textarea
id: tried-solutions
attributes:
label: Tried solutions
description: Have you tried solving the issue by adapting your Workflow? What steps did you take?
- type: textarea
id: example-workflow
attributes:
label: Example Workflow
description: Please share the YAML-code of your GitHub Actions workflow which causes the bug. We use this to reproduce the error. If the workflow is in a private repostory, please provide a minimal example. (No need for backticks here, the pasted code will be correctly formatted.)
render: yaml
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: If applicable, provide relevant log output. Please copy and paste the output here, and make sure to remove any sensitive information. (No need for backticks here, the pasted code will be correctly formatted.)
render: shell
- type: input
id: repository-url
attributes:
label: Repository
description: If applicable, please provide the repository where the bug occurred.
-38
View File
@@ -1,38 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
<!-- Before opening an issue, have you tried solving your problem by explicitly setting the `branch`-value in your workflow? -->
**Version of the Action**
`v4.x.x`
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Used Workflow**
```yaml
# Paste the Workflow you've used here
```
**Additional context**
Add any other context about the problem here.
+8
View File
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Get Help
url: https://github.com/stefanzweifel/git-auto-commit-action/discussions/new?category=help
about: If you can't get something to work the way you expect, open a question in our discussion forums.
- name: Feature Request
url: https://github.com/stefanzweifel/git-auto-commit-action/discussions/new?category=ideas
about: "Suggest any ideas you have using our discussion forums."
-20
View File
@@ -1,20 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
+3
View File
@@ -0,0 +1,3 @@
# Security Policy
If you discover any security related issues, please email stefan@stefanzweifel.dev instead of using the issue tracker.
+10
View File
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
+45
View File
@@ -0,0 +1,45 @@
ame-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
change-template: '- $TITLE ([#$NUMBER](https://github.com/stefanzweifel/git-auto-commit-action/pull/$NUMBER)) [@$AUTHOR](https://github.com/@$AUTHOR)'
template: |
$CHANGES
categories:
- title: Added
labels:
- 'changelog:added'
- title: Changed
labels:
- 'changelog:changed'
- title: Deprecated
labels:
- 'changelog:deprecated'
- title: Removed
labels:
- 'changelog:removed'
- title: Fixed
labels:
- 'changelog:fixed'
- title: Security
labels:
- security
- changelog:security
- title: 'Dependency Updates'
labels:
- dependencies
version-resolver:
major:
labels:
- 'changelog:removed'
minor:
labels:
- 'changelog:added'
- 'changelog:deprecated'
patch:
labels:
- 'changelog:fixed'
- 'changelog:security'
- 'dependency'
exclude-labels:
- 'skip-changelog'
+15 -4
View File
@@ -1,22 +1,33 @@
name: git-auto-commit
on: push
on:
push:
branches:
- master
pull_request:
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@v2
- uses: actions/checkout@v7
with:
ref: ${{ github.head_ref }}
- 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\""
+3 -2
View File
@@ -1,4 +1,5 @@
name: Lint Code Base
on: push
jobs:
@@ -8,10 +9,10 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v7
- name: Lint Code Base
uses: github/super-linter@v3
uses: github/super-linter@v7
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_MARKDOWN: false
+20
View File
@@ -0,0 +1,20 @@
name: Release Drafter
on:
push:
branches:
- master
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@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+6 -3
View File
@@ -1,17 +1,20 @@
name: tests
on: push
on:
push:
branches:
- master
pull_request:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7
- name: Install testing dependencies
run: yarn install
- name: Run Tests
run: yarn test
+34
View File
@@ -0,0 +1,34 @@
name: "Update Changelog"
on:
release:
types: [released]
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@v7
with:
ref: master
- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
release-notes: ${{ github.event.release.body }}
latest-version: ${{ github.event.release.name }}
- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v7
with:
branch: master
commit_message: Update CHANGELOG
file_pattern: CHANGELOG.md
+6
View File
@@ -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:
+280 -21
View File
@@ -1,199 +1,458 @@
# Changelog
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.8.0...HEAD)
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v7.1.0...HEAD)
> TBD
## [v7.1.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v7.0.0...v7.1.0) - 2025-12-17
### Added
- Add skip_push input option ([#401](https://github.com/stefanzweifel/git-auto-commit-action/pull/401)) [@kvanzuijlen](https://github.com/@kvanzuijlen)
### Changes
- docs: fix typo in README.md ([#400](https://github.com/stefanzweifel/git-auto-commit-action/pull/400)) [@GideonBear](https://github.com/@GideonBear)
### Dependency Updates
- Bump actions/checkout from 5 to 6 ([#399](https://github.com/stefanzweifel/git-auto-commit-action/pull/399)) [@[dependabot[bot]](https://github.com/apps/dependabot)](https://github.com/@[dependabot[bot]](https://github.com/apps/dependabot))
- Bump bats from 1.12.0 to 1.13.0 ([#398](https://github.com/stefanzweifel/git-auto-commit-action/pull/398)) [@[dependabot[bot]](https://github.com/apps/dependabot)](https://github.com/@[dependabot[bot]](https://github.com/apps/dependabot))
## [v7.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v6.0.1...v7.0.0) - 2025-10-12
### Added
- Restore skip_fetch, skip_checkout, create_branch ([#388](https://github.com/stefanzweifel/git-auto-commit-action/pull/388)) [@stefanzweifel](https://github.com/@stefanzweifel)
- Restore Detached State Detection ([#393](https://github.com/stefanzweifel/git-auto-commit-action/pull/393)) [@stefanzweifel](https://github.com/@stefanzweifel)
- Add Support for Tag Messages ([#391](https://github.com/stefanzweifel/git-auto-commit-action/pull/391)) [@EliasBoulharts](https://github.com/@EliasBoulharts)
### Changed
- Run Action on Node 24 ([#389](https://github.com/stefanzweifel/git-auto-commit-action/pull/389)) [@stefanzweifel](https://github.com/@stefanzweifel)
### Dependency Updates
- Bump actions/checkout from 4 to 5 ([#386](https://github.com/stefanzweifel/git-auto-commit-action/pull/386)) [@[dependabot[bot]](https://github.com/apps/dependabot)](https://github.com/@[dependabot[bot]](https://github.com/apps/dependabot))
## [v6.0.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v6.0.0...v6.0.1) - 2025-06-11
### Fixed
- Disable Check if Repo is in Detached State ([#379](https://github.com/stefanzweifel/git-auto-commit-action/pull/379)) [@stefanzweifel](https://github.com/@stefanzweifel)
## [v6.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.2.0...v6.0.0) - 2025-06-10
### Added
- Throw error early if repository is in a detached state ([#357](https://github.com/stefanzweifel/git-auto-commit-action/pull/357))
### Fixed
- Fix PAT instructions with Dependabot ([#376](https://github.com/stefanzweifel/git-auto-commit-action/pull/376)) [@Dreamsorcerer](https://github.com/@Dreamsorcerer)
### Removed
- Remove support for `create_branch`, `skip_checkout`, `skip_Fetch` ([#314](https://github.com/stefanzweifel/git-auto-commit-action/pull/314))
## [v5.2.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.1.0...v5.2.0) - 2025-04-19
### Added
- Add `create_git_tag_only` option to skip commiting and always create a git-tag. ([#364](https://github.com/stefanzweifel/git-auto-commit-action/pull/364)) [@zMynxx](https://github.com/@zMynxx)
- Add Test for `create_git_tag_only` feature ([#367](https://github.com/stefanzweifel/git-auto-commit-action/pull/367)) [@stefanzweifel](https://github.com/@stefanzweifel)
### Fixed
- docs: Update README.md per #354 ([#361](https://github.com/stefanzweifel/git-auto-commit-action/pull/361)) [@rasa](https://github.com/@rasa)
## [v5.1.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.0.1...v5.1.0) - 2025-01-11
### Changed
- Include `github.actor_id` in default `commit_author` ([#354](https://github.com/stefanzweifel/git-auto-commit-action/pull/354)) [@parkerbxyz](https://github.com/@parkerbxyz)
### Fixed
- docs(README): fix broken protected branch docs link ([#346](https://github.com/stefanzweifel/git-auto-commit-action/pull/346)) [@scarf005](https://github.com/@scarf005)
- Update README.md ([#343](https://github.com/stefanzweifel/git-auto-commit-action/pull/343)) [@Kludex](https://github.com/@Kludex)
### Dependency Updates
- Bump bats from 1.11.0 to 1.11.1 ([#353](https://github.com/stefanzweifel/git-auto-commit-action/pull/353)) [@dependabot](https://github.com/@dependabot)
- Bump github/super-linter from 6 to 7 ([#342](https://github.com/stefanzweifel/git-auto-commit-action/pull/342)) [@dependabot](https://github.com/@dependabot)
- Bump github/super-linter from 5 to 6 ([#335](https://github.com/stefanzweifel/git-auto-commit-action/pull/335)) [@dependabot](https://github.com/@dependabot)
## [v5.0.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.0.0...v5.0.1) - 2024-04-12
### Fixed
- Fail if attempting to execute git commands in a directory that is not a git-repo. ([#326](https://github.com/stefanzweifel/git-auto-commit-action/pull/326)) [@ccomendant](https://github.com/@ccomendant)
### Dependency Updates
- Bump bats from 1.10.0 to 1.11.0 ([#325](https://github.com/stefanzweifel/git-auto-commit-action/pull/325)) [@dependabot](https://github.com/@dependabot)
- Bump release-drafter/release-drafter from 5 to 6 ([#319](https://github.com/stefanzweifel/git-auto-commit-action/pull/319)) [@dependabot](https://github.com/@dependabot)
### Misc
- Clarify `commit_author` input option ([#315](https://github.com/stefanzweifel/git-auto-commit-action/pull/315)) [@npanuhin](https://github.com/@npanuhin)
- Add step id explanation for output in README.md ([#324](https://github.com/stefanzweifel/git-auto-commit-action/pull/324)) [@ChristianVermeulen](https://github.com/@ChristianVermeulen)
- Linux is not UNIX ([#321](https://github.com/stefanzweifel/git-auto-commit-action/pull/321)) [@couling](https://github.com/@couling)
## [v5.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.16.0...v5.0.0) - 2023-10-06
New major release that bumps the default runtime to Node 20. There are no other breaking changes.
### Changed
- Update node version to node20 ([#300](https://github.com/stefanzweifel/git-auto-commit-action/pull/300)) [@ryudaitakai](https://github.com/@ryudaitakai)
- Add _log and _set_github_output functions ([#273](https://github.com/stefanzweifel/git-auto-commit-action/pull/273)) [@stefanzweifel](https://github.com/@stefanzweifel)
### Fixed
- Seems like there is an extra space ([#288](https://github.com/stefanzweifel/git-auto-commit-action/pull/288)) [@pedroamador](https://github.com/@pedroamador)
- Fix git-auto-commit.yml ([#277](https://github.com/stefanzweifel/git-auto-commit-action/pull/277)) [@zcong1993](https://github.com/@zcong1993)
### Dependency Updates
- Bump actions/checkout from 3 to 4 ([#302](https://github.com/stefanzweifel/git-auto-commit-action/pull/302)) [@dependabot](https://github.com/@dependabot)
- Bump bats from 1.9.0 to 1.10.0 ([#293](https://github.com/stefanzweifel/git-auto-commit-action/pull/293)) [@dependabot](https://github.com/@dependabot)
- Bump github/super-linter from 4 to 5 ([#289](https://github.com/stefanzweifel/git-auto-commit-action/pull/289)) [@dependabot](https://github.com/@dependabot)
- Bump bats from 1.8.2 to 1.9.0 ([#282](https://github.com/stefanzweifel/git-auto-commit-action/pull/282)) [@dependabot](https://github.com/@dependabot)
## [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
- Let Action fail if git binary can't be located ([#261](https://github.com/stefanzweifel/git-auto-commit-action/pull/261)) [@stefanzweifel](https://github.com/@stefanzweifel)
### Dependency Updates
- Bump github/super-linter from 3 to 4 ([#258](https://github.com/stefanzweifel/git-auto-commit-action/pull/258)) [@dependabot](https://github.com/@dependabot)
- Bump bats from 1.7.0 to 1.8.2 ([#259](https://github.com/stefanzweifel/git-auto-commit-action/pull/259)) [@dependabot](https://github.com/@dependabot)
- Bump actions/checkout from 2 to 3 ([#257](https://github.com/stefanzweifel/git-auto-commit-action/pull/257)) [@dependabot](https://github.com/@dependabot)
## [v4.15.3](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.2...v4.15.3) - 2022-10-26
### Changed
- Use deprecated set-output syntax if GITHUB_OUTPUT environment is not available ([#255](https://github.com/stefanzweifel/git-auto-commit-action/pull/255)) [@stefanzweifel](https://github.com/@stefanzweifel)
## [v4.15.2](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.1...v4.15.2) - 2022-10-22
### Changed
- Replace set-output usage with GITHUB_OUTPUT ([#252](https://github.com/stefanzweifel/git-auto-commit-action/pull/252)) [@amonshiz](https://github.com/amonshiz)
## [v4.15.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.0...v4.15.1) - 2022-10-10
### Fixed
- Run Action on Node16 ([#247](https://github.com/stefanzweifel/git-auto-commit-action/pull/247)) [@stefanzweifel](https://github.com/@stefanzweifel)
## [v4.15.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.14.1...v4.15.0) - 2022-09-24
### Changed
- Expand `file_pattern`-input to an array ([#205](https://github.com/stefanzweifel/git-auto-commit-action/pull/205)) [@stefanzweifel](https://github.com/@stefanzweifel)
### Fixed
- String values in README.md extended example are now correct ([#196](https://github.com/stefanzweifel/git-auto-commit-action/pull/196)) [@karolswdev](https://github.com/@karolswdev)
- Fix Typos and grammer Errors in README ([#235](https://github.com/stefanzweifel/git-auto-commit-action/pull/235)) [@derrickleemy](https://github.com/@derrickleemy)
- Fix Typo in README ([#230](https://github.com/stefanzweifel/git-auto-commit-action/pull/230)) [@fty4](https://github.com/@fty4)
- Add missing links in the CHANGELOG ([#223](https://github.com/stefanzweifel/git-auto-commit-action/pull/223)) [@ericcornelissen](https://github.com/@ericcornelissen)
## [v4.14.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.14.0...v4.14.1) - 2022-04-12
## Changed
- Change Commit User Name from "GitHub Actions" to "github-actions[bot]" ([#213](https://github.com/stefanzweifel/git-auto-commit-action/pull/213)) @jooola
- Change Commit User Email from "actions@github.com" to "github-actions[bot]@users.noreply.github.com" ([#213](https://github.com/stefanzweifel/git-auto-commit-action/pull/213)) @jooola
## Fixed
- Update doc link to GITHUB_TOKEN not triggering new workflow runs ([#206](https://github.com/stefanzweifel/git-auto-commit-action/pull/206)) @gapple
## [v4.14.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.13.1...v4.14.0) - 2022-03-18
## Added
- Add `create_branch` option to force create a new branch ([#203](https://github.com/stefanzweifel/git-auto-commit-action/pull/203)) @stefanzweifel
## Fixed
- README.md: Updates hyperlink to GH docs ([#200](https://github.com/stefanzweifel/git-auto-commit-action/pull/200)) @funkyfuture
## [v4.13.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.13.0...v4.13.1) - 2022-01-13
## Fixed
- Properly disambiguate between branch or file checkout ([#199](https://github.com/stefanzweifel/git-auto-commit-action/pull/199)) @kenodegard
## [v4.13.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.12.0...v4.13.0) - 2022-01-10
## Added
- Add `skip_checkout` option ([#197](https://github.com/stefanzweifel/git-auto-commit-action/pull/197)) @cmbuckley
## Changed
- Add note on minimum permissions to the docs ([#180](https://github.com/stefanzweifel/git-auto-commit-action/pull/180)) @ericcornelissen
## [v4.12.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.11.0...v4.12.0) - 2021-09-10
### Added
- Add `commit_hash` output [#172](https://github.com/stefanzweifel/git-auto-commit-action/pull/172)
## [v4.11.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.10.0...v4.11.0) - 2021-05-03
### Added
- Add `status_options` and `add_options` option [#156](https://github.com/stefanzweifel/git-auto-commit-action/pull/156)
## [v4.10.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.9.2...v4.10.0) - 2021-04-12
### Added
- Add `disable_globbing` option [#153](https://github.com/stefanzweifel/git-auto-commit-action/issues/153), [#154](https://github.com/stefanzweifel/git-auto-commit-action/pull/154)
## [v4.9.2](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.9.1...v4.9.2) - 2021-03-04
### Fixes
- Push created annotated tags to remote by using `--follow-tags` and `--atomic` instead of just `--tags` [#146](https://github.com/stefanzweifel/git-auto-commit-action/pull/146)
## [v4.9.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.9.0...v4.9.1) - 2021-02-23
### Changed
- Revert changes made in v4.9.0. A branch will no longer be automatically generated. [#144](https://github.com/stefanzweifel/git-auto-commit-action/pull/144)
## [v4.9.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.8.0...v4.9.0) - 2021-02-20
### Changed
- Automatically create branch if a branch with the given name does not exist [#140](https://github.com/stefanzweifel/git-auto-commit-action/pull/140)
## [v4.8.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.7.2...v4.8.0) - 2020-12-15
### Added
- Add `skip_fetch` option to skip the execution of `git-fetch` [#131](https://github.com/stefanzweifel/git-auto-commit-action/pull/131)
### Changed
- Update `git fetch` to only fetch the latest commit from remote [#131](https://github.com/stefanzweifel/git-auto-commit-action/pull/131)
- Update `git fetch` to only fetch the latest commit from remote [#131](https://github.com/stefanzweifel/git-auto-commit-action/pull/131)
## [v4.7.2](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.7.1...v4.7.2) - 2020-10-24
This release basically reverts the Action to the state of `v4.6.0`.
### Changed
- Revert change to fix git-checkout with special characters in branch names [#122](https://github.com/stefanzweifel/git-auto-commit-action/pull/122)
- Revert change to fix git-checkout with special characters in branch names [#122](https://github.com/stefanzweifel/git-auto-commit-action/pull/122)
## [v4.7.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.7.0...v4.7.1) - 2020-10-22
### Removed
- Remove `checkout_options` as it broke everything [#120](https://github.com/stefanzweifel/git-auto-commit-action/pull/120/)
- Remove `checkout_options` as it broke everything [#120](https://github.com/stefanzweifel/git-auto-commit-action/pull/120/)
## [v4.7.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.6.0...v4.7.0) - 2020-10-21
### Added
- Add `checkout_options` [#115](https://github.com/stefanzweifel/git-auto-commit-action/pull/115)
- Add `checkout_options` [#115](https://github.com/stefanzweifel/git-auto-commit-action/pull/115)
## [v4.6.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.5.1...v4.6.0) - 2020-10-11
### Changed
- Make "commit_message" optional and set default commit message to "Apply automatic changes" [#103](https://github.com/stefanzweifel/git-auto-commit-action/issues/103), [#110](https://github.com/stefanzweifel/git-auto-commit-action/pull/110)
### Fixes
- Better support for branch names with special characters in them [#108](https://github.com/stefanzweifel/git-auto-commit-action/pull/108)
- Better support for branch names with special characters in them [#108](https://github.com/stefanzweifel/git-auto-commit-action/pull/108)
## [v4.5.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.5.0...v4.5.1) - 2020-09-11
### Removed
- Remove orphan branch feature added in #95 which broke stuff [#98](https://github.com/stefanzweifel/git-auto-commit-action/pull/98)
## [v4.5.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.4.1...v4.5.0) - 2020-09-10
### Added
- Create orphan branch if branch name does not exist [#95](https://github.com/stefanzweifel/git-auto-commit-action/pull/95)
## [v4.4.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.4.0...v4.4.1) - 2020-08-16
### Changed
- Include given `file_pattern` in git dirty check [#91](https://github.com/stefanzweifel/git-auto-commit-action/pull/91)
- Include given `file_pattern` in git dirty check [#91](https://github.com/stefanzweifel/git-auto-commit-action/pull/91)
## [v4.4.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.3.0...v4.4.0) - 2020-06-26
### Added
- Add option to skipt the dirty check and always try to create and push a commit [#82](https://github.com/stefanzweifel/git-auto-commit-action/issues/82), [#84](https://github.com/stefanzweifel/git-auto-commit-action/pull/84)
- Add option to skipt the dirty check and always try to create and push a commit [#82](https://github.com/stefanzweifel/git-auto-commit-action/issues/82), [#84](https://github.com/stefanzweifel/git-auto-commit-action/pull/84)
## [v4.3.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.2.0...v4.3.0) - 2020-05-16
Note: Since v4.3.0 we provide major version tags. You can now use `stefanzweifel/git-auto-commit-action@v4` to always use the latest release of a major version. See [#77](https://github.com/stefanzweifel/git-auto-commit-action/issues/77) for details.
### Added
- Add new `push_options`-input. This feature makes it easier for you to force-push commits to a repository. [#78](https://github.com/stefanzweifel/git-auto-commit-action/pull/78), [#72](https://github.com/stefanzweifel/git-auto-commit-action/issues/72)
- Add new `push_options`-input. This feature makes it easier for you to force-push commits to a repository. [#78](https://github.com/stefanzweifel/git-auto-commit-action/pull/78), [#72](https://github.com/stefanzweifel/git-auto-commit-action/issues/72)
## [v4.2.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.1.6...v4.2.0) - 2020-05-10
### Changed
- Use `${{ github.head_ref }}` as default branch value. Therefore, the branch name when listening for `pull_request`-events is optional. [#75](https://github.com/stefanzweifel/git-auto-commit-action/pull/75), [#73](https://github.com/stefanzweifel/git-auto-commit-action/pull/73)
- Use `${{ github.head_ref }}` as default branch value. Therefore, the branch name when listening for `pull_request`-events is optional. [#75](https://github.com/stefanzweifel/git-auto-commit-action/pull/75), [#73](https://github.com/stefanzweifel/git-auto-commit-action/pull/73)
## [v4.1.6](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.1.5...v4.1.6) - 2020-04-28
### Fixes
- Fix issue where tags could not be created correctly [#68](https://github.com/stefanzweifel/git-auto-commit-action/pull/68)
## [v4.1.5](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.1.4...v4.1.5) - 2020-04-23
### Added
- Update `file_pattern` to support multiple file paths [#65](https://github.com/stefanzweifel/git-auto-commit-action/pull/65)
### Changes
- Revert changes made in v4.1.4 [#63](https://github.com/stefanzweifel/git-auto-commit-action/pull/63)
### Fixes
- Fix issue with `commit_options` [#64](https://github.com/stefanzweifel/git-auto-commit-action/pull/64)
## [v4.1.4](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.1.3...v4.1.4) - 2020-04-22
### Fixed
- Fix bug introduced in previous version, where git user configuration has been placed inline [#62](https://github.com/stefanzweifel/git-auto-commit-action/pull/62)
- Fix bug introduced in previous version, where git user configuration has been placed inline [#62](https://github.com/stefanzweifel/git-auto-commit-action/pull/62)
## [v4.1.3](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.1.2...v4.1.3) - 2020-04-18
### Changed
- Place Git user configuration inline [#59](https://github.com/stefanzweifel/git-auto-commit-action/pull/59)
## [v4.1.2](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.1.1...v4.1.2) - 2020-04-03
### Fixes
- Fix Issue with `changes_detected`-output [#57](https://github.com/stefanzweifel/git-auto-commit-action/pull/57)
## [v4.1.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.1.0...v4.1.1) - 2020-03-14
### Fixes
- Fix issue where commit has not been pushed to remote repository, when no `branch`-option has been given [#54](https://github.com/stefanzweifel/git-auto-commit-action/pull/54)
- Fix issue where commit has not been pushed to remote repository, when no `branch`-option has been given [#54](https://github.com/stefanzweifel/git-auto-commit-action/pull/54)
## [v4.1.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.0.0...v4.1.0) - 2020-03-05
### Added
- Add `changes_detected` output [#49](https://github.com/stefanzweifel/git-auto-commit-action/pull/49), [#46](https://github.com/stefanzweifel/git-auto-commit-action/issues/46)
- Add `tagging_message` input option to create and push tags [#50](https://github.com/stefanzweifel/git-auto-commit-action/pull/50), [#47](https://github.com/stefanzweifel/git-auto-commit-action/issues/47)
## [v4.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v3.0.0...v4.0.0) - 2020-02-24
### Changed
- Switch Action to use `node12`-environment instead of `docker`. [#45](https://github.com/stefanzweifel/git-auto-commit-action/pull/45)
## [v3.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.5.0...v3.0.0) - 2020-02-06
### Added
- Add `commit_user_name`, `commit_user_email` and `commit_author` input options for full customzation on how the commit is being created [#39](https://github.com/stefanzweifel/git-auto-commit-action/pull/39)
### Changed
- Make the `branch` input option optional [#41](https://github.com/stefanzweifel/git-auto-commit-action/pull/41)
### Removed
- Remove the need of a GITHUB_TOKEN. Users now have to use `actions/checkout@v2` or higher [#36](https://github.com/stefanzweifel/git-auto-commit-action/pull/36)
- Remove the need of a GITHUB_TOKEN. Users now have to use `actions/checkout@v2` or higher [#36](https://github.com/stefanzweifel/git-auto-commit-action/pull/36)
## [v2.5.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.4.0...v2.5.0) - 2019-12-18
### Added
- Add new `repository`-argument [#22](https://github.com/stefanzweifel/git-auto-commit-action/pull/22)
### Changed
- Extract logic of the Action into methods and into a separate file [#24](https://github.com/stefanzweifel/git-auto-commit-action/pull/24)
- Extract logic of the Action into methods and into a separate file [#24](https://github.com/stefanzweifel/git-auto-commit-action/pull/24)
## [v2.4.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.3.0...v2.4.0) - 2019-11-30
### Added
- Commit untracked files [#19](https://github.com/stefanzweifel/git-auto-commit-action/pull/19) (fixes [#16](https://github.com/stefanzweifel/git-auto-commit-action/issues/16))
- Add support for Git-LFS [#21](https://github.com/stefanzweifel/git-auto-commit-action/pull/21) (fixes [#20](https://github.com/stefanzweifel/git-auto-commit-action/issues/20))
## [v2.3.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.2.0...v2.3.0) - 2019-11-04
### Added
- Add a new `commit_option`-argument. Allows users to define additional commit options for the `git-commit` command. [#14](https://github.com/stefanzweifel/git-auto-commit-action/pull/15)
- Add a new `commit_option`-argument. Allows users to define additional commit options for the `git-commit` command. [#14](https://github.com/stefanzweifel/git-auto-commit-action/pull/15)
## [v2.2.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.1.0...v2.2.0) - 2019-10-26
### Added
- Add new `file_pattern`-argument. Allows users to define which files should be added in the commit. [#13](https://github.com/stefanzweifel/git-auto-commit-action/pull/13)
- Add new `file_pattern`-argument. Allows users to define which files should be added in the commit. [#13](https://github.com/stefanzweifel/git-auto-commit-action/pull/13)
## [v2.1.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.0.0...v2.1.0) - 2019-09-20
### Added
- Add `branch`-argument to determine, to which branch changes should be pushed. See README for usage details.
### Fixed
- Fixes Issue where changes couldn't be pushed to GitHub due to wrong ref-name.
### Removed
- Remove `commit_author_email` and `commit_author_name` arguments. The `$GITHUB_ACTOR` is now used as the Git Author
- Remove `commit_author_email` and `commit_author_name` arguments. The `$GITHUB_ACTOR` is now used as the Git Author
## [v2.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v1.0.0...v2.0.0) - 2019-08-31
### Changed
- Make Action Compatible with latest beta of GitHub Actions [#3](https://github.com/stefanzweifel/git-auto-commit-action/pull/3)
- Make Action Compatible with latest beta of GitHub Actions [#3](https://github.com/stefanzweifel/git-auto-commit-action/pull/3)
## v1.0.0 - 2019-06-10
### Added
- Add Core Logic for Action
+2 -3
View File
@@ -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.
@@ -72,5 +72,4 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
For answers to common questions about this code of conduct, see the [Contributor Covenant FAQ](https://www.contributor-covenant.org/faq).
+551
View File
@@ -0,0 +1,551 @@
# Examples
This document shows real-world scenarios where `git-auto-commit` is useful, with a working GitHub Actions workflow for each. The scenarios are based on questions and use cases that have come up in the [issues](https://github.com/stefanzweifel/git-auto-commit-action/issues) and [discussions](https://github.com/stefanzweifel/git-auto-commit-action/discussions) of this repository over the years.
If you have a use case that isn't covered here, [open a discussion](https://github.com/stefanzweifel/git-auto-commit-action/discussions) — we may add it.
## Table of Contents
- [Auto-format code on pull requests](#auto-format-code-on-pull-requests)
- [Auto-fix lint errors](#auto-fix-lint-errors)
- [Update dependency lock files](#update-dependency-lock-files)
- [Build and commit compiled assets](#build-and-commit-compiled-assets)
- [Auto-generate API documentation](#auto-generate-api-documentation)
- [Update README with generated content](#update-readme-with-generated-content)
- [Maintain a CHANGELOG](#maintain-a-changelog)
- [Sync translations / i18n files](#sync-translations--i18n-files)
- [Publish a static site to a separate branch](#publish-a-static-site-to-a-separate-branch)
- [Scheduled data refresh](#scheduled-data-refresh)
- [Create a release tag without a commit](#create-a-release-tag-without-a-commit)
- [Fail the build instead of pushing changes (drift check)](#fail-the-build-instead-of-pushing-changes-drift-check)
- [Sign automated commits with GPG](#sign-automated-commits-with-gpg)
- [Squash automated changes into the previous commit](#squash-automated-changes-into-the-previous-commit)
---
## Auto-format code on pull requests
**Description:** Run a code formatter (Prettier, php-cs-fixer, Black, gofmt, rustfmt, …) on every pull request and commit the resulting changes back to the contributor's branch. Contributors don't have to think about style; the bot fixes it for them.
This is the most common use case for this Action. Running it on `pull_request` means the formatter only touches the PR branch — never your default branch directly.
```yaml
name: Format
on: pull_request
jobs:
prettier:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npx prettier --write .
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "style: apply prettier formatting"
```
> [!TIP]
> If the PR comes from a fork, the Action can only push back if the contributor enabled "Allow edits by maintainers". See the [forks section in the README](README.md#use-in-forks-from-public-repositories) for details.
---
## Auto-fix lint errors
**Description:** Many linters can both report and auto-fix problems (`eslint --fix`, `rubocop -a`, `ruff --fix`, `stylelint --fix`, …). Use the Action to commit the auto-fixed result so reviewers only see the issues that need human judgement.
```yaml
name: Lint and fix
on: pull_request
jobs:
eslint:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npx eslint . --fix
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "chore: apply eslint --fix"
```
> [!TIP]
> `file_pattern` is intentionally omitted here. If one of several custom patterns does not match a file in the repository, `git add` can fail with a pathspec error. Let the linter decide which files to change, or use a custom pattern that you know exists in your repository.
---
## Update dependency lock files
**Description:** When a dependency tool produces a fresh lock file (`package-lock.json`, `composer.lock`, `Gemfile.lock`, `poetry.lock`, …), commit only the lock file. Pair this with a scheduled job to keep lock files in sync without manual intervention.
```yaml
name: Refresh lock file
on:
schedule:
- cron: "0 6 * * 1" # every Monday at 06:00 UTC
workflow_dispatch:
jobs:
refresh:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install --package-lock-only
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "chore(deps): refresh package-lock.json"
file_pattern: package-lock.json
```
---
## Build and commit compiled assets
**Description:** For projects that ship a `dist/` folder (libraries, browser extensions, themes), build the assets in CI and commit them so consumers can install directly from the repo without a build step.
```yaml
name: Build dist
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run build
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "build: update dist/"
file_pattern: "dist/**"
```
> [!NOTE]
> If `dist/` is in `.gitignore`, the Action will not pick up changes. See the [troubleshooting section in the README](README.md#change-to-file-is-not-detected).
---
## Auto-generate API documentation
**Description:** Tools like TypeDoc, Doxygen, Sphinx, or `cargo doc` generate documentation from source comments. Regenerate on every push to `main` and commit the output so the published docs always match the latest code.
```yaml
name: Docs
on:
push:
branches: [main]
jobs:
typedoc:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npx typedoc --out docs/api src/index.ts
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "docs: regenerate API reference"
file_pattern: "docs/api/**"
```
---
## Update README with generated content
**Description:** Many projects keep dynamic sections in the README — a contributor list, a badge gallery, a table of contents, a list of supported plugins. Regenerate them on a schedule (or when a related file changes) and commit the result.
```yaml
name: Update contributors
on:
schedule:
- cron: "0 0 * * 0" # weekly
workflow_dispatch:
jobs:
contributors:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- uses: akhilmhdh/contributors-readme-action@v2.3.10
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "docs: update contributors"
file_pattern: README.md
```
---
## Maintain a CHANGELOG
**Description:** Generate or update `CHANGELOG.md` from commit history or release notes after each merge to `main`, and commit it back.
```yaml
name: Update CHANGELOG
on:
push:
branches: [main]
jobs:
changelog:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # full history so the generator sees all commits
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npx conventional-changelog -p angular -i CHANGELOG.md -s
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "docs: update CHANGELOG"
file_pattern: CHANGELOG.md
```
---
## Sync translations / i18n files
**Description:** When translations are managed in an external service (Crowdin, Lokalise, Weblate) or extracted from source, pull or generate the latest catalogs on a schedule and commit them.
```yaml
name: Sync translations
on:
schedule:
- cron: "0 3 * * *" # daily at 03:00 UTC
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- name: Download translations
run: ./scripts/pull-translations.sh
env:
CROWDIN_TOKEN: ${{ secrets.CROWDIN_TOKEN }}
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "i18n: sync translations from Crowdin"
file_pattern: "locales/**/*.json"
```
---
## Publish a static site to a separate branch
**Description:** Build a static site on `main` and push the generated output to a `gh-pages` branch so GitHub Pages can serve it. Use a second checkout directory for the publish branch so the source checkout and generated site do not get mixed together.
Create the `gh-pages` branch once before using this workflow.
```yaml
name: Build site
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
path: source
- uses: actions/checkout@v5
with:
ref: gh-pages
path: site
- name: Build site
working-directory: source
run: ./build-site.sh # produces output in ./public
- name: Replace publish branch contents
run: |
find site -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
cp -R source/public/. site/
- uses: stefanzweifel/git-auto-commit-action@v7
with:
repository: site
branch: gh-pages
commit_message: "site: rebuild from ${{ github.sha }}"
```
> [!NOTE]
> For most Pages workflows the official [`actions/deploy-pages`](https://github.com/actions/deploy-pages) is a better fit. Use this approach when you specifically want the build output stored in a branch.
---
## Scheduled data refresh
**Description:** Pull data from an external source on a schedule and commit it. Common examples: tracking statistics, snapshotting an API response, refreshing a cached dataset.
```yaml
name: Refresh stats
on:
schedule:
- cron: "0 * * * *" # hourly
workflow_dispatch:
jobs:
refresh:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- run: curl -sSL https://api.example.com/stats.json -o data/stats.json
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "data: refresh hourly stats"
file_pattern: "data/*.json"
```
---
## Create a release tag without a commit
**Description:** Sometimes you want to tag the current HEAD as a release without committing any files. Use `create_git_tag_only` together with `tag_name` and `tagging_message`.
```yaml
name: Tag release
on:
workflow_dispatch:
inputs:
version:
description: "Version to tag (e.g. v1.4.0)"
required: true
jobs:
tag:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- uses: stefanzweifel/git-auto-commit-action@v7
with:
create_git_tag_only: true
tag_name: ${{ inputs.version }}
tagging_message: "Release ${{ inputs.version }}"
```
---
## Fail the build instead of pushing changes (drift check)
**Description:** Sometimes you don't want a bot to push fixes — you want to fail the build so the contributor fixes them locally. Use the `changes_detected` output as a check: run the formatter, skip branch checkout/fetch/push, and fail if anything changed.
```yaml
name: Format check
on: pull_request
jobs:
check:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npx prettier --write .
- uses: stefanzweifel/git-auto-commit-action@v7
id: auto-commit
with:
skip_checkout: true
skip_fetch: true
skip_push: true
- name: Fail if formatting was needed
if: steps.auto-commit.outputs.changes_detected == 'true'
run: |
echo "::error::Code is not formatted. Run 'npx prettier --write .' locally."
exit 1
```
---
## Sign automated commits with GPG
**Description:** If your branch protection rules require signed commits, the bot's commits need to be signed too. Import a GPG key first, then tell the Action to use the key's identity as the commit author.
```yaml
name: Format (signed)
on: pull_request
jobs:
format:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.head_ref }}
- name: Import GPG key
id: import-gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- run: npx prettier --write .
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "style: apply prettier"
commit_user_name: ${{ steps.import-gpg.outputs.name }}
commit_user_email: ${{ steps.import-gpg.outputs.email }}
commit_author: "${{ steps.import-gpg.outputs.name }} <${{ steps.import-gpg.outputs.email }}>"
```
See discussion [#334](https://github.com/stefanzweifel/git-auto-commit-action/discussions/334) for background.
---
## Squash automated changes into the previous commit
**Description:** Avoid noisy "apply automatic changes" commits by amending the last commit instead. Useful when the bot fix is trivial and you don't want a separate entry in the history.
> [!CAUTION]
> Amending rewrites history. Only use this on branches where force-pushing is acceptable (typically PR branches, never `main`).
```yaml
name: Format (amend)
on: pull_request
jobs:
format:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.head_ref }}
fetch-depth: 2 # need previous commit for --amend
- run: npx prettier --write .
- name: Read previous commit metadata
id: last
run: |
echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
echo "author=$(git log -1 --pretty='%an <%ae>')" >> $GITHUB_OUTPUT
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: ${{ steps.last.outputs.message }}
commit_author: ${{ steps.last.outputs.author }}
commit_options: "--amend --no-edit"
push_options: "--force"
skip_fetch: true
```
See discussion [#159](https://github.com/stefanzweifel/git-auto-commit-action/issues/159#issuecomment-845347950) for details.
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019 Stefan Zweifel
Copyright (c) 2021 Stefan Zweifel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+473 -97
View File
@@ -2,75 +2,163 @@
> The GitHub Action for committing files for the 80% use case.
<a href="https://github.com/search?o=desc&q=stefanzweifel%2Fgit-auto-commit-action+path%3A.github%2Fworkflows+language%3AYAML&s=&type=Code" target="_blank" title="Public workflows that use this action."><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fapi-git-master.endbug.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3Dstefanzweifel%2Fgit-auto-commit-action%26badge%3Dtrue" alt="Public workflows that use this action."></a>
<a href="https://github.com/stefanzweifel/git-auto-commit-action/actions?query=workflow%3Atests">
<img src="https://github.com/stefanzweifel/git-auto-commit-action/workflows/tests/badge.svg" alt="">
</a>
This GitHub Action automatically commits files which have been changed during a Workflow run and pushes the commit back to GitHub.
A GitHub Action to detect changed files during a Workflow run and to commit and push them back to the GitHub repository.
By default, the commit is made in the name of "GitHub Actions" and co-authored by the user that made the last commit.
This Action has been inspired and adapted from the [auto-commit](https://github.com/cds-snc/github-actions/tree/master/auto-commit
)-Action of the Canadian Digital Service and this [commit](https://github.com/elstudio/actions-js-build/blob/41d604d6e73d632e22eac40df8cc69b5added04b/commit/entrypoint.sh)-Action by Eric Johnson.
If you want to learn more how this Action works under the hood, check out [this article](https://michaelheap.com/git-auto-commit/) by Michael Heap.
If your use case is not covered by git-auto-commit, you might want to check out the following alternative Actions:
- [planetscale/ghcommit-action](https://github.com/planetscale/ghcommit-action)
- [EndBug/add-and-commit](https://github.com/EndBug/add-and-commit)
## 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 `write`. (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
- uses: stefanzweifel/git-auto-commit-action@v7
```
This is a more extended example with all possible options.
Your Workflow should look similar to this example.
```yaml
- uses: stefanzweifel/git-auto-commit-action@v4
with:
# Optional but recommended
# Defaults to "Apply automatic changes"
commit_message: Apply automatic changes
name: Format
# Optional branch name where commit should be pushed to
# Defaults to the current branch
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@v5
with:
ref: ${{ github.head_ref }}
# Value already defaults to true, but `persist-credentials` is required to push new commits to the repository.
persist-credentials: true
# Other steps that change files in the repository go here
# …
# Commit all changed files back to the repository
- uses: stefanzweifel/git-auto-commit-action@v7
```
> [!NOTE]
> The Action has to be used in a Job that runs on a UNIX-like system (e.g. `ubuntu-latest`).
The following is an extended example with all available options.
```yaml
- uses: stefanzweifel/git-auto-commit-action@v7
with:
# Optional. Commit message for the created commit.
# Defaults to "Apply automatic changes"
commit_message: Automated Change
# Optional. Remote branch name where commit is going to be pushed to.
# Defaults to the current branch.
branch: feature-123
# Optional options appended to `git-commit`
# See https://git-scm.com/docs/git-commit for a list of available options
# Optional. Options used by `git-commit`.
# See https://git-scm.com/docs/git-commit#_options
commit_options: '--no-verify --signoff'
# Optional glob pattern of files which should be added to the commit
# Optional glob pattern of files which should be added to the commit
# Defaults to all (.)
# See the `pathspec`-documentation for git
# - https://git-scm.com/docs/git-add#Documentation/git-add.txt-ltpathspecgt82308203
# - https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec
file_pattern: src/*.js tests/*.js *.php
file_pattern: '*.php src/*.js tests/*.js'
# Optional local file path to the repository
# Defaults to the root of the repository
# Optional. Relative file path under $GITHUB_WORKSPACE to the repository.
# Defaults to the root of the repository.
repository: .
# Optional commit user and author settings
commit_user_name: My GitHub Actions Bot # defaults to "GitHub Actions"
commit_user_email: my-github-actions-bot@example.org # defaults to "actions@github.com"
commit_author: Author <actions@github.com> # defaults to author of the commit that triggered the run
commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]"
commit_user_email: my-github-actions-bot@example.org # defaults to "41898282+github-actions[bot]@users.noreply.github.com"
commit_author: Author <actions@github.com> # defaults to "username <numeric_id+username@users.noreply.github.com>", where "numeric_id" and "username" belong to the author of the commit that triggered the run
# Optional tag message
# Action will create and push a new tag to the remote repository and the defined branch
tagging_message: 'v1.0.0'
# Optional. Tag name to be created in the local repository and
# pushed to the remote repository on the defined branch.
# If only one of `tag_name` or `tagging_message` is provided, the value of the provided field will be used for both tag name and message.
tag_name: 'v1.0.0'
# Optional options appended to `git-push`
# See git-push documentation for details: https://git-scm.com/docs/git-push#_options
# Optional. Message to annotate the created tag with.
# If only one of `tag_name` or `tagging_message` is provided, the value of the provided field will be used for both tag name and message.
tagging_message: 'Codename "Sunshine"'
# Optional. Option used by `git-status` to determine if the repository is
# dirty. See https://git-scm.com/docs/git-status#_options
status_options: '--untracked-files=no'
# Optional. Options used by `git-add`.
# See https://git-scm.com/docs/git-add#_options
add_options: '-u'
# Optional. Options used by `git-push`.
# See https://git-scm.com/docs/git-push#_options
push_options: '--force'
# Optional: Disable dirty check and always try to create a commit and push
# Optional. Disable dirty check and always try to create a commit and push
skip_dirty_check: true
# Optional: Skip internal call to `git fetch`
# Optional. Skip internal call to `git fetch`
skip_fetch: true
# Optional. Skip internal call to `git checkout`
skip_checkout: true
# Optional. Skip internal call to `git push`
skip_push: true
# Optional. Prevents the shell from expanding filenames.
# Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html
disable_globbing: true
# Optional. Create given branch name in local and remote repository.
create_branch: true
# Optional. Creates a new tag and pushes it to remote without creating a commit.
# Skips dirty check and changed files. Must be used in combination with `tag` and `tagging_message`.
create_git_tag_only: false
# Optional. Suppress the security warning emitted when the action runs on a
# `pull_request_target` event. See the "Workflow should run in **base** repository"
# section below for context before disabling this warning.
disable_pull_request_target_trigger_warning: false
# Optional. Shell snippets to run around each git operation. Each hook
# is evaluated in the same bash process as the action — `set -eu` is
# in effect, the working directory is your repository, and all
# `INPUT_*` env vars are visible. A non-zero exit aborts the action.
before_add_hook: ''
after_add_hook: ''
before_commit_hook: ''
after_commit_hook: ''
before_tag_hook: ''
after_tag_hook: ''
before_push_hook: ''
after_push_hook: ''
```
## Example
Please note that the Action depends on `bash`. If you're using the Action in a job in combination with a custom Docker container, make sure that `bash` is installed.
## Example Workflow
In this example, we're running `php-cs-fixer` in a PHP project to fix the codestyle automatically, then commit possible changed files back to the repository.
@@ -84,25 +172,31 @@ on:
pull_request:
push:
branches:
- "main"
- main
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@v5
with:
ref: ${{ github.head_ref }}
- name: Run php-cs-fixer
uses: docker://oskarstark/php-cs-fixer-ga
- uses: stefanzweifel/git-auto-commit-action@v4
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: Apply php-cs-fixer changes
```
See [EXAMPLES.md](EXAMPLES.md) for more scenarios, including auto-formatting, dependency updates, generated docs, release tagging, drift checks, and GPG-signed commits.
## Inputs
Checkout [`action.yml`](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/action.yml) for a full list of supported inputs.
@@ -112,10 +206,19 @@ Checkout [`action.yml`](https://github.com/stefanzweifel/git-auto-commit-action/
You can use these outputs to trigger other Actions in your Workflow run based on the result of `git-auto-commit-action`.
- `changes_detected`: Returns either "true" or "false" if the repository was dirty and files have changed.
- `commit_hash`: Returns the full hash of the commit if one was created.
- `create_git_tag_only`: Returns either "true" or "false" if a tag was created, when `create_git_tag_only` was used.
**⚠️ When using outputs, the step needs to be given an id. See example below.**
### Example
```yaml
- uses: stefanzweifel/git-auto-commit-action@v7
id: auto-commit-action #mandatory for the output to show up in ${{ steps }}
with:
commit_message: Apply php-cs-fixer changes
- name: "Run if changes have been detected"
if: steps.auto-commit-action.outputs.changes_detected == 'true'
run: echo "Changes!"
@@ -125,25 +228,120 @@ You can use these outputs to trigger other Actions in your Workflow run based on
run: echo "No Changes!"
```
## Hooks
git-auto-commit can run custom shell snippets around each git operation
it performs. This is useful when you need to prepare or clean up the
repository as part of the same step — for example, unshallowing a
shallow clone right before the commit is staged.
Eight optional hooks are available:
| Hook | Runs |
| ---- | ---- |
| `before_add_hook` / `after_add_hook` | around `git add` |
| `before_commit_hook` / `after_commit_hook` | around `git commit` |
| `before_tag_hook` / `after_tag_hook` | around `git tag` (only when a tag is being created) |
| `before_push_hook` / `after_push_hook` | around `git push` (skipped when `skip_push: true`) |
Each hook is an inline shell snippet that runs in the same bash process
as the action. The working directory is your repository, and all
`INPUT_*` environment variables and standard GitHub Actions env vars are
visible to the snippet.
### Example
```yaml
- uses: stefanzweifel/git-auto-commit-action@v7
with:
before_add_hook: |
git fetch --unshallow
```
Multi-line snippets work via YAML's `|` block scalar:
```yaml
- uses: stefanzweifel/git-auto-commit-action@v7
with:
before_commit_hook: |
echo "About to commit at $(date)"
./scripts/prepare-commit.sh
```
### Notes
- A hook only runs when its underlying step actually runs. For example,
`before_add_hook`/`after_add_hook` are skipped when the working tree is clean,
and `before_push_hook`/`after_push_hook` are skipped when `skip_push: true`.
- If a hook exits with a non-zero status, the action fails. Append
`|| true` to a snippet to ignore its failure.
- Hooks share environment with the action, so they can read action
inputs (e.g. `$INPUT_COMMIT_MESSAGE`) and write to `$GITHUB_OUTPUT`.
- Snippets run under `set -eu`. Referencing an unset variable aborts the
action; use `${VAR:-}` to default an optional variable to empty.
### Security
Hook snippets are evaluated as shell code in the same process as the
action. Treat them as you would any `run:` step.
> [!CAUTION]
> **Do not combine hooks with the `pull_request_target` event when the
> snippet references attacker-controlled GitHub context.** Fields like
> `${{ github.event.pull_request.title }}`, `${{ github.event.pull_request.body }}`,
> `${{ github.head_ref }}`, and commit messages from a fork are
> interpolated into the snippet **before** bash sees it. A malicious PR
> can inject shell commands that run on your runner with access to your
> repository secrets. See the [`pull_request_target` section](#workflow-should-run-in-base-repository)
> for the broader risk and [GitHub's script-injection guidance](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#understanding-the-risk-of-script-injections).
If you need values from PR-controlled context inside a hook, pass them
via an intermediate env var rather than interpolating them directly into
the snippet:
```yaml
- uses: stefanzweifel/git-auto-commit-action@v7
env:
PR_TITLE: ${{ github.event.pull_request.title }}
with:
before_commit_hook: |
# $PR_TITLE is read as data, not evaluated as code
echo "PR: $PR_TITLE"
```
## Limitations & Gotchas
The goal of this Action is to be "the Action for committing files for the 80% use case". Therefore, you might run into issues if your Workflow falls into the not supported 20% portion.
The following is a list of edge cases the Action knowingly does not support:
**No `git pull` when the repository is out of date with remote.** The Action will not do a `git pull` before doing the `git push`. **You** are responsible for keeping the repository up to date in your Workflow runs.
**No support for running the Action in build matrices**. If your Workflow is using build matrices, and you want that each job commits and pushes files to the remote, you will run into the issue, that the repository in the workflow will become out of date. As the Action will not do a `git pull` for you, you have to do that yourself.
**No support for `git rebase` or `git merge`**. There are many strategies on how to integrate remote upstream changes to a local repository. `git-auto-commit` does not want to be responsible for doing that.
**No support for detecting line break changes between CR (Carriage Return) and LF (Line Feed)**. This is a low level issue, you have to resolve differently in your project. Sorry.
If this Action doesn't work for your workflow, check out [EndBug/add-and-commit](https://github.com/EndBug/add-and-commit).
### Checkout the correct branch
You must use `action/checkout@v2` or later versions to checkout the repository.
You must use `actions/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@v5
with:
ref: ${{ github.head_ref }}
```
You have to do this to avoid that the `checkout`-Action clones your repository in a detached state.
Do this to avoid checking out the repository in a detached state.
### Commits of this Action do not trigger new Workflow runs
### Commits made by this Action do not trigger new Workflow runs
The resulting commit **will not trigger** another GitHub Actions Workflow run.
This is due to [limititations set by GitHub](https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token).
This is due to [limitations set by GitHub](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow).
> When you use the repository's GITHUB_TOKEN to perform tasks on behalf of the GitHub Actions app, events triggered by the GITHUB_TOKEN will not create a new workflow run. This prevents you from accidentally creating recursive workflow runs.
@@ -151,82 +349,207 @@ 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@v5
with:
token: ${{ secrets.PAT }}
```
If you work in an organization and don't want to create a PAT from your personal account, we recommend using a [robot account](https://docs.github.com/en/github/getting-started-with-github/types-of-github-accounts) for the token.
If you create a personal access token (classic), apply the `repo` and `workflow` scopes.
If you create a fine-grained personal access token, apply the `Contents`-permissions.
If you work in an organization and don't want to create a PAT from your personal account, we recommend using a [robot account](https://docs.github.com/en/get-started/learning-about-github/types-of-github-accounts) for the token.
### Prevent Infinite Loop when using a Personal Access Token
If you're using a Personal Access Token (PAT) to push commits to GitHub repository, the resulting commit or push can trigger other GitHub Actions workflows. This can result in an infinite loop.
If you would like to prevent this, you can add `skip-checks:true` to the commit message. See [Skipping workflow runs](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/skip-workflow-runs) for details.
### 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.
## 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/reference/workflows-and-actions/workflow-commands#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@v7
id: commit
with:
commit_message: ${{ steps.commit_message_step.outputs.commit_message }}
```
### Signing Commits
If you would like to sign your commits using a GPG key, you will need to use an additional action.
You can use the [crazy-max/ghaction-import-gpg](https://github.com/crazy-max/ghaction-import-gpg) action and follow its setup instructions.
As git-auto-commit by default does not use **your** username and email when creating a commit, you have to override these values in your workflow.
```yml
- name: "Import GPG key"
id: import-gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: "Commit and push changes"
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_author: "${{ steps.import-gpg.outputs.name }} <${{ steps.import-gpg.outputs.email }}>"
commit_user_name: ${{ steps.import-gpg.outputs.name }}
commit_user_email: ${{ steps.import-gpg.outputs.email }}
```
See discussion [#334](https://github.com/stefanzweifel/git-auto-commit-action/discussions/334) for details.
### Use in forks from private repositories
### Using the Action in forks from public 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.
**☝️ 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.
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/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#enabling-workflows-for-private-repository-forks) for details.
---
### Use in forks from public repositories
> [!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/actions/reference/workflows-and-actions/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 Action in Workflows that should be triggered by forked repositories.
If you want that a Workflow using this Action runs on Pull Requests opened by forks, 2 things have to be changed:
### Workflow should run in **base** repository
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).
2. GitHub Action has to be enabled on the forked repository. \
For security reasons, GitHub does not automatically enable GitHub Actions on forks. The user has to explicitly enable GitHub Actions in the "Actions"-tab of the forked repository. (Mention this in your projects README or CONTRIBUTING.md!)
> [!CAUTION]
> The following section explains how you can use git-auto-commit in combination with the `pull_request_target` trigger.
> **Using `pull_request_target` in your workflows can lead to repository compromise as [mentioned](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) by GitHub's own security team. This means, that a bad actor could potentially leak/steal your GitHub Actions repository secrets.**
> Please be aware of this risk when using `pull_request_target` in your workflows. See [GitHub's documentation](https://docs.github.com/en/actions/reference/security/securely-using-pull_request_target) for more information.
>
> If your workflow runs code-fixing tools, consider running the workflow on your default branch by listening to the `push` event or use a third-party tool like [autofix.ci](https://autofix.ci/).
> We keep this documentation around, as many questions came in over the years, on how to use this action for public forks.
>
> To remind users of this risk, git-auto-commit emits a warning annotation whenever it detects it is running on a `pull_request_target` event.
> If you have evaluated the risk and want to silence the warning, set the `disable_pull_request_target_trigger_warning` input to `true`.
>
> **Extra caution if you also use [hooks](#hooks):** hook snippets are evaluated as shell code. Interpolating attacker-controlled fields (PR title/body, branch name, fork commit messages, etc.) directly into a hook input on a `pull_request_target` workflow lets a malicious PR run arbitrary commands on your runner with access to your secrets. Pass such values through an `env:` block and reference them as `$VARS` inside the snippet — see the [Security note in the Hooks section](#security) for an example.
After you have added the `pull_request_target` to your desired Workflow and the forked repository has enabled Actions and a new Pull Request is opened, the Workflow will run **on the forked repository**.
The workflow below runs whenever a commit is pushed to the `main`-branch or when activity on a pull request happens, by listening to the [`pull_request_target`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target) event.
Due to the fact that the Workflow is not run on the repository the Pull Request is opened in, you won't see any status indicators inside the Pull Request.
If the workflow is triggered by the `pull_request_target`-event, the workflow will run in the context of the base of the pull request, rather than in the context of the merge commit, as the `pull_request` event does.
In other words, this will allow your workflow to be run in the repository where the pull request is opened to and will push changes back to the fork.
#### Example
The following workflow runs `php-cs-fixer` (a code linter and fixer for PHP) when a `pull_request` is opened. We've added the `pull_request_target`-trigger too, to make it work for forks.
Check out the discussion in [#211](https://github.com/stefanzweifel/git-auto-commit-action/issues/211) for more information on this.
```yaml
name: Format PHP
on: [push, pull_request, pull_request_target]
on:
push:
branches:
- main
pull_request_target:
jobs:
php-cs-fixer:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
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
uses: docker://oskarstark/php-cs-fixer-ga
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply php-cs-fixer changes
- uses: stefanzweifel/git-auto-commit-action@v7
```
Next time a user forks your project **and** enabled GitHub Actions **and** opened a Pull Request, the Workflow will run on the the forked repository and will push commits to the same branch.
Here's how the Pull Request will look like:
![Screenshot of a Pull Request from a Fork](https://user-images.githubusercontent.com/1080923/90955964-9c74c080-e482-11ea-8097-aa7f5161f50e.png)
As you can see, your contributors have to go through hoops to make this work. **For Workflows which runter linters and fixers (like the example above) we recommend running them when a push happens on the `master`-branch.**
For more information about running Actions on forks, see [this announcement from GitHub](https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/).
### Push to forks from private repositories
### Using `--amend` and `--no-edit` as commit options
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.
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.
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.
> [!CAUTION]
> 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).
### Signing Commits & Other Git Command Line Options
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.
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 regulary
By default, the commit author is changed to `username <username@users.noreply.github.com>`, where `username` is the name of the user who triggered the workflow (The [`github.actor`](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context) context is used here). If you want to preserve the name and email of the original author, you must extract them from the last commit and provide them to the Action through the `commit_author` input option.
- [Import GPG Signature](https://github.com/crazy-max/ghaction-import-gpg) (Suggested by [TGTGamer](https://github.com/tgtgamer))
Finally, you have to use `push_options: '--force'` to overwrite the git history on the GitHub remote repository. (git-auto-commit will not do a `git-rebase` for you!)
The steps in your workflow might look like this:
```yaml
- uses: actions/checkout@v4
with:
# Fetch the last 2 commits instead of just 1. (Fetching just 1 commit would overwrite the whole history)
fetch-depth: 2
# Other steps in your workflow to trigger a changed file
- name: Get last commit message
id: last-commit
run: |
echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
echo "author=$(git log -1 --pretty=\"%an <%ae>\")" >> $GITHUB_OUTPUT
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_author: ${{ steps.last-commit.outputs.author }}
commit_message: ${{ steps.last-commit.outputs.message }}
commit_options: '--amend --no-edit'
push_options: '--force'
skip_fetch: true
```
See discussion in [#159](https://github.com/stefanzweifel/git-auto-commit-action/issues/159#issuecomment-845347950) for details.
## Troubleshooting
### Action does not push commit to repository
Make sure to [checkout the correct branch](#checkout-the-correct-branch).
@@ -236,40 +559,85 @@ Make sure to [checkout the correct branch](#checkout-the-correct-branch).
If your Workflow can't push the commit to the repository because of authentication issues,
please update your Workflow configuration and usage of [`actions/checkout`](https://github.com/actions/checkout#usage).
Updating the `token` value with a Personal Access Token should fix your issues.
Please note that `persist-credentials` in `actions/checkout` must be set to `true` to push new commits to the repository.
If you still can't push the commit, and you're using branch protection rules or similar features, updating the `token` value with a Personal Access Token should fix your issues.
### git-auto-commit fails to push commit that creates or updates files in `.github/workflows/`
The default `GITHUB_TOKEN` issued by GitHub Action does not have permission to make changes to workflow files located in `.github/workflows/`.
To fix this, please create a personal access token (PAT) and pass the token to the `actions/checkout`-step in your workflow. (Similar to [how to push to protected branches](https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#push-to-protected-branches)).
If a PAT does not work for you, you could also create a new GitHub app and use its token in your workflows. See [this comment in #87](https://github.com/stefanzweifel/git-auto-commit-action/issues/87#issuecomment-1939138661) for details.
See [#322](https://github.com/stefanzweifel/git-auto-commit-action/issues/322) for details and discussions around this topic.
### Push to protected branches
If your repository uses [protected branches](https://help.github.com/en/github/administering-a-repository/configuring-protected-branches) you have to do the following changes to your Workflow for the Action to work properly.
If your repository uses [protected branches](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches) you have to make some changes to your Workflow for the Action to work properly: You need a Personal Access Token and you either have to allow force pushes or the Personal Access Token needs to belong to an Administrator.
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.
First, you have to create a new [Personal Access Token (PAT)](https://github.com/settings/tokens/new),
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.
If you create a personal access token (classic), apply the `repo` and `workflow` scopes.
If you create a fine-grained personal access token, apply the `Contents`-permissions.
```yaml
- uses: stefanzweifel/git-auto-commit-action@v4
- uses: actions/checkout@v5
with:
# We pass the "PAT" secret to the checkout action; if no PAT secret is available to the workflow runner (eg. Dependabot) we fall back to the default "GITHUB_TOKEN".
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
```
You can learn more about Personal Access Token in the [GitHub documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens).
> [!TIP]
> 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://docs.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)) and update your Workflow to use force push like this.
```yaml
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: Apply php-cs-fixer changes
push_options: --force
```
In addition, you have to create a new [Personal Access Token (PAT)](https://github.com/settings/tokens/new),
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
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.
### No new workflows are triggered by the commit of this action
This is due to limitations set up by GitHub, [commits of this Action do not trigger new Workflow runs](#commits-of-this-action-do-not-trigger-new-workflow-runs).
This is due to limitations set up by GitHub, [commits made by this Action do not trigger new Workflow runs](#commits-made-by-this-action-do-not-trigger-new-workflow-runs).
### Pathspec 'x' did not match any files
If you're using the Action with a custom `file_pattern` and the Action throws a fatal error with the message "Pathspec 'file-pattern' did not match any files", the problem is probably that no file for the pattern **exists** in the repository.
`file_pattern` is used both for `git-status` and `git-add` in this Action. `git-add` will throw a fatal error, if for example, you use a file pattern like `*.js *.ts` but no `*.ts` files exist in your projects' repository.
See [Issue #227](https://github.com/stefanzweifel/git-auto-commit-action/issues/227) for details.
### Custom `file_pattern`, changed files but seeing "Working tree clean. Nothing to commit." in the logs
If you're using a custom `file_pattern` and the Action does not detect the changes made in your workflow, you're probably running into a globbing issue.
Let's imagine you use `file_pattern: '*.md'` to detect and commit changes to all Markdown files in your repository.
If your Workflow now only updates `.md`-files in a subdirectory, but you have an untouched `.md`-file in the root of the repository, the git-auto-commit Action will display "Working tree clean. Nothing to commit." in the Workflow log.
This is due to the fact, that the `*.md`-glob is expanded before sending it to `git-status`. `git-status` will receive the filename of your untouched `.md`-file in the root of the repository and won't detect any changes; and therefore the Action does nothing.
To fix this add `disable_globbing: true` to your Workflow.
```yaml
- uses: stefanzweifel/git-auto-commit-action@v7
with:
file_pattern: '*.md'
disable_globbing: true
```
See [Issue #239](https://github.com/stefanzweifel/git-auto-commit-action/issues/239) for details.
## Running the tests
The package has tests written in [bats](https://github.com/bats-core/bats-core). Before you can run the test suite locally, you have to install the dependencies with `npm` or `yarn`.
The Action has tests written in [bats](https://github.com/bats-core/bats-core). Before you can run the test suite locally, you have to install the dependencies with `npm` or `yarn`.
```shell
npm install
@@ -285,10 +653,18 @@ yarn test
## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/stefanzweifel/git-auto-commit-action/tags).
We use [SemVer](https://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/stefanzweifel/git-auto-commit-action/tags).
We also provide major version tags to make it easier to always use the latest release of a major version. For example you can use `stefanzweifel/git-auto-commit-action@v4` to always use the latest release of the current major version.
(More information about this [here](https://help.github.com/en/actions/building-actions/about-actions#versioning-your-action).)
We also provide major version tags to make it easier to always use the latest release of a major version. For example, you can use `stefanzweifel/git-auto-commit-action@v7` to always use the latest release of the current major version.
(More information about this [here](https://docs.github.com/en/actions/building-actions/about-actions#versioning-your-action).)
## Credits
* [Stefan Zweifel](https://github.com/stefanzweifel)
* [All Contributors](https://github.com/stefanzweifel/git-auto-commit-action/graphs/contributors)
This Action has been inspired and adapted from the [auto-commit](https://github.com/cds-snc/github-actions/tree/master/auto-commit
)-Action of the Canadian Digital Service and this [commit](https://github.com/elstudio/actions-js-build/blob/41d604d6e73d632e22eac40df8cc69b5added04b/commit/entrypoint.sh)-Action by Eric Johnson.
## License
+18
View File
@@ -0,0 +1,18 @@
# Upgrading
## From v6 to v7
The previously removed options `create_branch`, `skip_fetch`, and `skip_checkout` have been reintroduced in git-auto-commit v7. If you had removed these options from your workflows when upgrading to v6, you can now add them back if needed.
Tagging a commit has been reworked. In addition to the existing `tagging_message`-option, a new `tag_name` option has been added. If you were using `tagging_message`, you can continue to do so, but if you want to specify a custom tag name and tag message, you can now use the `tag_name` and `tagging_message` options.
(Specifying a `tagging_message` without a `tag_name` will create a tag with the name and message both set to the value of `tagging_message`.)
## From v5 to v6
The following options have been removed from git-auto-commit and can be removed from your workflows.
- `create_branch` (git-auto-commit no longer switches branches locally during a workflow run)
- `skip_fetch`
- `skip_checkout`
+86 -9
View File
@@ -1,7 +1,7 @@
name: Git Auto Commit
description: 'Automatically commits files which have been changed during the workflow run and push changes back to remote repository.'
author: Stefan Zweifel <hello@stefanzweifel.io>
author: Stefan Zweifel <stefan@stefanzweifel.dev>
inputs:
commit_message:
@@ -16,28 +16,40 @@ inputs:
description: Commit options (eg. --no-verify)
required: false
default: ''
add_options:
description: Add options (eg. -u)
required: false
default: ''
status_options:
description: Status options (eg. --untracked-files=no)
required: false
default: ''
file_pattern:
description: File pattern used for `git add`. For example `src/\*.js`
description: File pattern used for `git add` and the dirty-check (`git status`). Supports multiple space-separated patterns. For example `src/*.js`
required: false
default: '.'
repository:
description: Local file path to the git repository. Defaults to the current directory (`.`)
description: Relative file path under $GITHUB_WORKSPACE to the git repository. Defaults to the current directory (`.`)
required: false
default: '.'
commit_user_name:
description: Name used for the commit user
required: false
default: GitHub Actions
default: github-actions[bot]
commit_user_email:
description: Email address used for the commit user
required: false
default: actions@github.com
default: 41898282+github-actions[bot]@users.noreply.github.com
commit_author:
description: Value used for the commit author. Defaults to the username of whoever triggered this workflow run.
required: false
default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
default: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
tag_name:
description: Tag name used for creating a new git tag with the commit. Keep this empty, if no tag should be created.
required: false
default: ''
tagging_message:
description: Message used to create a new git tag with the commit. Keep this empty, if no tag should be created.
description: Tagging message used for creating a new git tag with the commit. Keep this empty, if no tag should be created.
required: false
default: ''
push_options:
@@ -52,13 +64,78 @@ inputs:
description: Skip the call to git-fetch.
required: false
default: false
skip_checkout:
description: Skip the call to git-checkout.
required: false
default: false
skip_push:
description: Skip the call to git-push.
required: false
default: false
disable_globbing:
description: Stop the shell from expanding filenames (https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html)
required: false
default: false
create_branch:
description: Create new branch with the name of `branch`-input in local and remote repository, if it doesn't exist yet.
required: false
default: false
create_git_tag_only:
description: Perform a clean git tag and push, without commiting anything
required: false
default: false
before_add_hook:
description: Shell snippet to run before `git add`.
required: false
default: ''
after_add_hook:
description: Shell snippet to run after `git add`.
required: false
default: ''
before_commit_hook:
description: Shell snippet to run before `git commit`.
required: false
default: ''
after_commit_hook:
description: Shell snippet to run after `git commit`.
required: false
default: ''
before_tag_hook:
description: Shell snippet to run before `git tag` is created.
required: false
default: ''
after_tag_hook:
description: Shell snippet to run after `git tag` is created.
required: false
default: ''
before_push_hook:
description: Shell snippet to run before `git push`.
required: false
default: ''
after_push_hook:
description: Shell snippet to run after `git push`.
required: false
default: ''
disable_pull_request_target_trigger_warning:
description: Suppress the security warning emitted when the action runs on a `pull_request_target` event.
required: false
default: false
internal_git_binary:
description: Internal use only! Path to git binary used to check if git is available. (Don't change this!)
required: false
default: git
outputs:
changes_detected:
description: Value is "true", if the repository was dirty and file changes have been detected. Value is "false", if no changes have been detected.
description: Value is "true" if matching changes were detected and committed. Value is "false" if no matching changes were detected or only CRLF changes were staged. Not set in `create_git_tag_only` mode.
commit_hash:
description: Full hash of the created commit. Only set when a commit was actually made (i.e. `changes_detected` is "true").
create_git_tag_only:
description: Set to "true" when the action ran in `create_git_tag_only` mode. Never set to "false".
runs:
using: 'node12'
using: 'node24'
main: 'index.js'
branding:
+183 -25
View File
@@ -2,30 +2,124 @@
set -eu
if "$INPUT_DISABLE_GLOBBING"; then
set -o noglob;
fi
_set_github_output() {
local name=${1}
local value=${2}
# Check if $GITHUB_OUTPUT is available
# (Feature detection will be removed in spring 2023)
if [ -z ${GITHUB_OUTPUT+x} ]; then
echo "::set-output name=$name::$value";
else
echo "$name=$value" >> $GITHUB_OUTPUT;
fi
}
_log() {
local level=${1}
local message=${2}
echo "::$level::$message";
}
_run_hook() {
local name=${1}
local snippet=${2:-}
if [ -n "$snippet" ]; then
_log "debug" "Running $name";
eval "$snippet"
fi
}
_main() {
_check_if_git_is_available
_switch_to_repository
if _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then
_check_if_is_git_repository
echo "::set-output name=changes_detected::true";
_check_if_repository_is_in_detached_state
_check_for_pull_request_target_trigger
if "$INPUT_CREATE_GIT_TAG_ONLY"; then
_log "debug" "Create git tag only";
_set_github_output "create_git_tag_only" "true"
if [ -n "$INPUT_TAG_NAME" ] || [ -n "$INPUT_TAGGING_MESSAGE" ]; then
_run_hook "before_tag_hook" "$INPUT_BEFORE_TAG_HOOK"
_tag_commit
_run_hook "after_tag_hook" "$INPUT_AFTER_TAG_HOOK"
else
_tag_commit
fi
if ! "$INPUT_SKIP_PUSH"; then
_run_hook "before_push_hook" "$INPUT_BEFORE_PUSH_HOOK"
fi
_push_to_github
if ! "$INPUT_SKIP_PUSH"; then
_run_hook "after_push_hook" "$INPUT_AFTER_PUSH_HOOK"
fi
elif _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then
_set_github_output "changes_detected" "true"
_switch_to_branch
_run_hook "before_add_hook" "$INPUT_BEFORE_ADD_HOOK"
_add_files
_run_hook "after_add_hook" "$INPUT_AFTER_ADD_HOOK"
# Check dirty state of repo again using git-diff.
# (git-diff detects better if CRLF of files changes and does NOT
# proceed, if only CRLF changes are detected. See #241 and #265
# for more details.)
if [ -n "$(git diff --staged)" ] || "$INPUT_SKIP_DIRTY_CHECK"; then
_run_hook "before_commit_hook" "$INPUT_BEFORE_COMMIT_HOOK"
_local_commit
_run_hook "after_commit_hook" "$INPUT_AFTER_COMMIT_HOOK"
if [ -n "$INPUT_TAG_NAME" ] || [ -n "$INPUT_TAGGING_MESSAGE" ]; then
_run_hook "before_tag_hook" "$INPUT_BEFORE_TAG_HOOK"
_tag_commit
_push_to_github
_run_hook "after_tag_hook" "$INPUT_AFTER_TAG_HOOK"
else
_tag_commit
fi
echo "::set-output name=changes_detected::false";
if ! "$INPUT_SKIP_PUSH"; then
_run_hook "before_push_hook" "$INPUT_BEFORE_PUSH_HOOK"
fi
_push_to_github
if ! "$INPUT_SKIP_PUSH"; then
_run_hook "after_push_hook" "$INPUT_AFTER_PUSH_HOOK"
fi
else
_set_github_output "changes_detected" "false"
echo "Working tree clean. Nothing to commit.";
fi
else
_set_github_output "changes_detected" "false"
echo "Working tree clean. Nothing to commit.";
fi
}
_check_if_git_is_available() {
if hash -- "$INPUT_INTERNAL_GIT_BINARY" 2> /dev/null; then
_log "debug" "git binary found.";
else
_log "error" "git-auto-commit could not find git binary. Please make sure git is available."
exit 1;
fi
}
_switch_to_repository() {
echo "INPUT_REPOSITORY value: $INPUT_REPOSITORY";
@@ -33,36 +127,89 @@ _switch_to_repository() {
}
_git_is_dirty() {
echo "INPUT_STATUS_OPTIONS: ${INPUT_STATUS_OPTIONS}";
_log "debug" "Apply status options ${INPUT_STATUS_OPTIONS}";
echo "INPUT_FILE_PATTERN: ${INPUT_FILE_PATTERN}";
read -r -a INPUT_FILE_PATTERN_EXPANDED <<< "$INPUT_FILE_PATTERN";
# capture stderr
gitStatusMessage="$((git status -s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED:+${INPUT_FILE_PATTERN_EXPANDED[@]}} >/dev/null ) 2>&1)";
# shellcheck disable=SC2086
[ -n "$(git status -s -- $INPUT_FILE_PATTERN)" ]
gitStatus="$(git status -s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED:+${INPUT_FILE_PATTERN_EXPANDED[@]}})";
[ -n "$gitStatus" ]
}
_check_if_is_git_repository() {
if [ -d ".git" ]; then
_log "debug" "Repository found.";
else
_log "error" "Not a git repository. Please make sure to run this action in a git repository. Adjust the `repository` input if necessary.";
exit 1;
fi
}
_check_for_pull_request_target_trigger() {
if "$INPUT_DISABLE_PULL_REQUEST_TARGET_TRIGGER_WARNING"; then
return
fi
if [ "${GITHUB_EVENT_NAME:-}" = "pull_request_target" ]; then
_log "warning" "git-auto-commit is running on a 'pull_request_target' event. This trigger can be a security risk: a malicious pull request could potentially exfiltrate your repository secrets. See https://docs.github.com/en/actions/reference/security/securely-using-pull_request_target and the 'pull_request_target' section in the git-auto-commit README (https://github.com/stefanzweifel/git-auto-commit-action#using-the-action-in-a-pull_request_target-workflow) for safer usage. Set 'disable_pull_request_target_trigger_warning: true' to suppress this warning.";
fi
}
_check_if_repository_is_in_detached_state() {
if [ -z "$(git symbolic-ref HEAD)" ]
then
_log "warning" "Repository is in a detached HEAD state. git-auto-commit will likely handle this automatically. To avoid it, check out a branch using the ref option in actions/checkout.";
else
_log "debug" "Repository is on a branch.";
fi
}
_switch_to_branch() {
echo "INPUT_BRANCH value: $INPUT_BRANCH";
# Fetch remote to make sure that repo can be switched to the right branch.
# Fetch remote to make sure that repo can be switched to the right branch.
if "$INPUT_SKIP_FETCH"; then
echo "::debug::git-fetch has not been executed";
_log "debug" "git-fetch will not be executed.";
else
_log "debug" "git-fetch will be executed.";
git fetch --depth=1;
fi
# If `skip_checkout`-input is true, skip the entire checkout step.
if "$INPUT_SKIP_CHECKOUT"; then
_log "debug" "git-checkout will not be executed.";
else
_log "debug" "git-checkout will be executed.";
# Create new local branch if `create_branch`-input is true
if "$INPUT_CREATE_BRANCH"; then
# shellcheck disable=SC2086
git checkout -B $INPUT_BRANCH --;
else
# Switch to branch from current Workflow run
# shellcheck disable=SC2086
git checkout $INPUT_BRANCH;
git checkout $INPUT_BRANCH --;
fi
fi
}
_add_files() {
echo "INPUT_ADD_OPTIONS: ${INPUT_ADD_OPTIONS}";
_log "debug" "Apply add options ${INPUT_ADD_OPTIONS}";
echo "INPUT_FILE_PATTERN: ${INPUT_FILE_PATTERN}";
read -r -a INPUT_FILE_PATTERN_EXPANDED <<< "$INPUT_FILE_PATTERN";
# shellcheck disable=SC2086
git add ${INPUT_FILE_PATTERN};
git add ${INPUT_ADD_OPTIONS} ${INPUT_FILE_PATTERN:+"${INPUT_FILE_PATTERN_EXPANDED[@]}"};
}
_local_commit() {
echo "INPUT_COMMIT_OPTIONS: ${INPUT_COMMIT_OPTIONS}";
echo "::debug::Apply commit options ${INPUT_COMMIT_OPTIONS}";
_log "debug" "Apply commit options ${INPUT_COMMIT_OPTIONS}";
# shellcheck disable=SC2206
INPUT_COMMIT_OPTIONS_ARRAY=( $INPUT_COMMIT_OPTIONS );
@@ -76,43 +223,54 @@ _local_commit() {
commit -m "$INPUT_COMMIT_MESSAGE" \
--author="$INPUT_COMMIT_AUTHOR" \
${INPUT_COMMIT_OPTIONS:+"${INPUT_COMMIT_OPTIONS_ARRAY[@]}"};
_set_github_output "commit_hash" $(git rev-parse HEAD)
}
_tag_commit() {
echo "INPUT_TAG_NAME: ${INPUT_TAG_NAME}"
echo "INPUT_TAGGING_MESSAGE: ${INPUT_TAGGING_MESSAGE}"
if [ -n "$INPUT_TAGGING_MESSAGE" ]
then
echo "::debug::Create tag $INPUT_TAGGING_MESSAGE";
git -c user.name="$INPUT_COMMIT_USER_NAME" -c user.email="$INPUT_COMMIT_USER_EMAIL" tag -a "$INPUT_TAGGING_MESSAGE" -m "$INPUT_TAGGING_MESSAGE";
if [ -n "$INPUT_TAG_NAME" ] || [ -n "$INPUT_TAGGING_MESSAGE" ]; then
INTERNAL_TAG=${INPUT_TAG_NAME:-$INPUT_TAGGING_MESSAGE}
INTERNAL_TAGGING_MESSAGE=${INPUT_TAGGING_MESSAGE:-$INPUT_TAG_NAME}
_log "debug" "Create tag $INTERNAL_TAG: $INTERNAL_TAGGING_MESSAGE"
git -c user.name="$INPUT_COMMIT_USER_NAME" -c user.email="$INPUT_COMMIT_USER_EMAIL" tag -a "$INTERNAL_TAG" -m "$INTERNAL_TAGGING_MESSAGE"
else
echo "No tagging message supplied. No tag will be added.";
echo "Neither tag nor tag message is set. No tag will be added.";
fi
}
_push_to_github() {
if "$INPUT_SKIP_PUSH"; then
_log "debug" "git-push will not be executed.";
return
fi
echo "INPUT_BRANCH value: $INPUT_BRANCH";
echo "INPUT_PUSH_OPTIONS: ${INPUT_PUSH_OPTIONS}";
echo "::debug::Apply push options ${INPUT_PUSH_OPTIONS}";
_log "debug" "Apply push options ${INPUT_PUSH_OPTIONS}";
# shellcheck disable=SC2206
INPUT_PUSH_OPTIONS_ARRAY=( $INPUT_PUSH_OPTIONS );
if [ -z "$INPUT_BRANCH" ]
then
# Only add `--tags` option, if `$INPUT_TAGGING_MESSAGE` is set
if [ -n "$INPUT_TAGGING_MESSAGE" ]
# Only add `--tags` option, if `$INPUT_TAG_NAME` or `$INPUT_TAGGING_MESSAGE` is set
if [ -n "$INPUT_TAG_NAME" ] || [ -n "$INPUT_TAGGING_MESSAGE" ]
then
echo "::debug::git push origin --tags";
git push origin --tags ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
_log "debug" "git push origin --tags";
git push origin --follow-tags --atomic ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
else
echo "::debug::git push origin";
_log "debug" "git push origin";
git push origin ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
fi
else
echo "::debug::Push commit to remote branch $INPUT_BRANCH";
git push --set-upstream origin "HEAD:$INPUT_BRANCH" --tags ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
_log "debug" "Push commit to remote branch $INPUT_BRANCH";
git push --set-upstream origin "HEAD:$INPUT_BRANCH" --follow-tags --atomic ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
fi
}
+37
View File
@@ -0,0 +1,37 @@
{
"name": "git-auto-commit-action",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"devDependencies": {
"bats": "^1.13.0",
"bats-assert": "ztombol/bats-assert",
"bats-support": "ztombol/bats-support"
}
},
"node_modules/bats": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/bats/-/bats-1.13.0.tgz",
"integrity": "sha512-giSYKGTOcPZyJDbfbTtzAedLcNWdjCLbXYU3/MwPnjyvDXzu6Dgw8d2M+8jHhZXSmsCMSQqCp+YBsJ603UO4vQ==",
"dev": true,
"license": "MIT",
"bin": {
"bats": "bin/bats"
}
},
"node_modules/bats-assert": {
"version": "0.3.0",
"resolved": "git+ssh://git@github.com/ztombol/bats-assert.git#9f88b4207da750093baabc4e3f41bf68f0dd3630",
"dev": true,
"peerDependencies": {
"bats-support": "git+https://github.com/ztombol/bats-support.git#v0.2.0"
}
},
"node_modules/bats-support": {
"version": "0.3.0",
"resolved": "git+ssh://git@github.com/ztombol/bats-support.git#004e707638eedd62e0481e8cdc9223ad471f12ee",
"dev": true
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"devDependencies": {
"bats": "^1.1.0",
"bats": "^1.13.0",
"bats-assert": "ztombol/bats-assert",
"bats-support": "ztombol/bats-support"
},
+1511 -60
View File
File diff suppressed because it is too large Load Diff
-16
View File
@@ -1,16 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
bats-assert@ztombol/bats-assert:
version "0.3.0"
resolved "https://codeload.github.com/ztombol/bats-assert/tar.gz/9f88b4207da750093baabc4e3f41bf68f0dd3630"
bats-support@ztombol/bats-support:
version "0.3.0"
resolved "https://codeload.github.com/ztombol/bats-support/tar.gz/004e707638eedd62e0481e8cdc9223ad471f12ee"
bats@^1.1.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/bats/-/bats-1.2.1.tgz#c15aecc3eb331aedf28678880fab2be0b73eba43"
integrity sha512-2fcPDRQa/Kvh6j1IcCqsHpT5b9ObMzRzw6abC7Bg298PX8Qdh9VRkvO2WJUEhdyfjq2rLBCOAWdcv0tS4+xTUA==