mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2025-07-30 22:46:13 +08:00
Compare commits
45 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
5804e42f86 | ||
|
e3cb9ba079 | ||
|
af49309116 | ||
|
b244c38293 | ||
|
c463ede7c3 | ||
|
8040434425 | ||
|
fc174e2406 | ||
|
8c3ed373fb | ||
|
797544dbd2 | ||
|
0d6c97e470 | ||
|
f6048aa2ac | ||
|
983386a337 | ||
|
b8ff4cd716 | ||
|
abd87b7d94 | ||
|
54cc2186d1 | ||
|
216b25a401 | ||
|
05aea7e2d9 | ||
|
68fd92dd9c | ||
|
0426839718 | ||
|
97badfaf41 | ||
|
10257e2994 | ||
|
e107e28c4e | ||
|
6834afe239 | ||
|
27ac2f0a7b | ||
|
3568db7bbc | ||
|
053f356774 | ||
|
46af2f08b3 | ||
|
5dd17c3b53 | ||
|
ebbf8e517a | ||
|
76f1ae2f1a | ||
|
b9c536534c | ||
|
68f0d95687 | ||
|
ccad85927e | ||
|
48d37c1ffb | ||
|
4c05e3d58e | ||
|
3053f48bdd | ||
|
cfd366418e | ||
|
be370eccae | ||
|
f4f9aedbee | ||
|
e610a5104b | ||
|
be7095c202 | ||
|
ae9ae1b5b8 | ||
|
e944668910 | ||
|
9bb0fd2324 | ||
|
175c2cd836 |
45
.github/release-drafter.yml
vendored
Normal file
45
.github/release-drafter.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
ame-template: 'v$RESOLVED_VERSION'
|
||||
tag-template: 'v$RESOLVED_VERSION'
|
||||
template: |
|
||||
# What's Changed
|
||||
$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'
|
6
.github/workflows/git-auto-commit.yml
vendored
6
.github/workflows/git-auto-commit.yml
vendored
@@ -1,6 +1,10 @@
|
||||
name: git-auto-commit
|
||||
|
||||
on: push
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
git-auto-commit:
|
||||
|
1
.github/workflows/linter.yml
vendored
1
.github/workflows/linter.yml
vendored
@@ -1,4 +1,5 @@
|
||||
name: Lint Code Base
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
|
14
.github/workflows/release-drafter.yml
vendored
Normal file
14
.github/workflows/release-drafter.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
name: Release Drafter
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
update_release_draft:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: release-drafter/release-drafter@v5
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
7
.github/workflows/tests.yml
vendored
7
.github/workflows/tests.yml
vendored
@@ -1,6 +1,10 @@
|
||||
name: tests
|
||||
|
||||
on: push
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
@@ -14,4 +18,3 @@ jobs:
|
||||
|
||||
- name: Run Tests
|
||||
run: yarn test
|
||||
|
||||
|
28
.github/workflows/update-changelog.yaml
vendored
Normal file
28
.github/workflows/update-changelog.yaml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
name: "Update Changelog"
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [released]
|
||||
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
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@v4
|
||||
with:
|
||||
branch: master
|
||||
commit_message: Update CHANGELOG
|
||||
file_pattern: CHANGELOG.md
|
95
CHANGELOG.md
95
CHANGELOG.md
@@ -1,211 +1,260 @@
|
||||
# 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.9.1...HEAD)
|
||||
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.13.0...HEAD)
|
||||
|
||||
> TBD
|
||||
|
||||
## [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) @cmbuckley
|
||||
|
||||
## Changed
|
||||
|
||||
- Add note on minimum permissions to the docs (#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)
|
||||
|
||||
- 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)
|
||||
|
||||
- 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
|
||||
|
||||
|
165
README.md
165
README.md
@@ -7,12 +7,9 @@
|
||||
<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.
|
||||
|
||||
## Usage
|
||||
@@ -23,25 +20,27 @@ Add the following step at the end of your job, after other steps that might add
|
||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||
```
|
||||
|
||||
Note that the Action has to be used in a Job that runs on a UNIX system (eg. `ubuntu-latest`).
|
||||
If you don't use the default permission of the GITHUB_TOKEN, give the Job or Workflow at least the `contents: write` permission.
|
||||
|
||||
This is a more extended example with all possible options.
|
||||
The following is an extended example with all possible options available for this Action.
|
||||
|
||||
```yaml
|
||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
# Optional but recommended
|
||||
# Optional, but recommended
|
||||
# Defaults to "Apply automatic changes"
|
||||
commit_message: Apply automatic changes
|
||||
commit_message: Automated Change
|
||||
|
||||
# Optional branch name where commit should be pushed to
|
||||
# Defaults to the current branch
|
||||
# Optional branch name where commit should 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. 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
|
||||
@@ -61,18 +60,35 @@ This is a more extended example with all possible options.
|
||||
# Action will create and push a new tag to the remote repository and the defined branch
|
||||
tagging_message: 'v1.0.0'
|
||||
|
||||
# Optional options appended to `git-push`
|
||||
# See git-push documentation for details: https://git-scm.com/docs/git-push#_options
|
||||
# Optional. Used by `git-status`
|
||||
# See https://git-scm.com/docs/git-status#_options
|
||||
status_options: '--untracked-files=no'
|
||||
|
||||
# Optional. Used by `git-add`
|
||||
# See https://git-scm.com/docs/git-add#_options
|
||||
add_options: '-u'
|
||||
|
||||
# Optional. 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`
|
||||
skip_fetch: true
|
||||
# Optional. Skip internal call to `git fetch`
|
||||
skip_fetch: true
|
||||
|
||||
# Optional. Skip internal call to `git checkout`
|
||||
skip_checkout: true
|
||||
|
||||
# Optional. Prevents the shell from expanding filenames.
|
||||
# Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html
|
||||
disable_globbing: true
|
||||
```
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -114,6 +130,7 @@ 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.
|
||||
|
||||
### Example
|
||||
|
||||
@@ -129,6 +146,18 @@ You can use these outputs to trigger other Actions in your Workflow run based on
|
||||
|
||||
## 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 the date with remote.** The 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**. For example, 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.
|
||||
|
||||
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.
|
||||
@@ -142,7 +171,7 @@ In non-`push` events, such as `pull_request`, make sure to specify the `ref` to
|
||||
|
||||
You have to do this to avoid that the `checkout`-Action clones your 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 [limitations set by GitHub](https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token).
|
||||
@@ -160,8 +189,10 @@ storing the token as a secret in your repository and then passing the new token
|
||||
|
||||
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.
|
||||
|
||||
## Advanced Uses
|
||||
|
||||
### Using the Action in forks from public repositories
|
||||
<details>
|
||||
<summary>Use in forks from public repositories</summary>
|
||||
|
||||
**☝️ Important Notice**: This Action technically works with forks. However, please note that the combination of triggers and their options can cause issues. Please read [the documentation](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows) on which triggers GitHub Actions support.\
|
||||
If you use this Action in combination with a linter/fixer, it's easier if you run the Action on `push` on your `main`-branch.
|
||||
@@ -210,23 +241,76 @@ Here's how the Pull Request will look like:
|
||||

|
||||
|
||||
|
||||
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.**
|
||||
As you can see, your contributors have to go through hoops to make this work. **For Workflows which run linters and fixers (like the example above) we recommend running them when a push happens on the `main`-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
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Push to forks from private repositories</summary>
|
||||
|
||||
By default, GitHub Actions doesn't run Workflows on forks from private repositories. To enable Actions for **private** repositories enable "Run workflows from pull requests" in your repository settings.
|
||||
|
||||
See [this announcement from GitHub](https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/) or the [GitHub docs](https://docs.github.com/en/github/administering-a-repository/disabling-or-limiting-github-actions-for-a-repository#enabling-workflows-for-private-repository-forks) for details.
|
||||
|
||||
### Signing Commits & Other Git Command Line Options
|
||||
</details>
|
||||
|
||||
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
|
||||
<details>
|
||||
<summary>
|
||||
Signing Commits & Other Git Command Line Options
|
||||
</summary>
|
||||
|
||||
Using command lines options needs to be done manually for each workflow which you require the option enabled. So for example signing commits requires you to import the gpg signature each and every time. The following list of actions are worth checking out if you need to automate these tasks regulary.
|
||||
|
||||
- [Import GPG Signature](https://github.com/crazy-max/ghaction-import-gpg) (Suggested by [TGTGamer](https://github.com/tgtgamer))
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
Using `--amend` and `--no-edit` as commit options
|
||||
</summary>
|
||||
|
||||
|
||||
|
||||
|
||||
If you would like to use this Action to create a commit using [`--amend`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend) and [`--no-edit`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---no-edit) you need to make some adjustments.
|
||||
|
||||
**☝️ Important Notice:** You should understand the implications of rewriting history if you amend a commit that has already been published. [See rebasing](https://git-scm.com/docs/git-rebase#_recovering_from_upstream_rebase)
|
||||
|
||||
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.
|
||||
|
||||
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@master
|
||||
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-message
|
||||
run: |
|
||||
echo "::set-output name=msg::$(git log -1 --pretty=%s)"
|
||||
|
||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: ${{ steps.last-commit-message.outputs.msg }}
|
||||
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.
|
||||
|
||||
</details>
|
||||
|
||||
## Troubleshooting
|
||||
### Action does not push commit to repository
|
||||
@@ -242,18 +326,9 @@ Updating the `token` value with a Personal Access Token should fix your issues.
|
||||
|
||||
### 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://help.github.com/en/github/administering-a-repository/configuring-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 Acess 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.
|
||||
|
||||
```yaml
|
||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||
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),
|
||||
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.
|
||||
|
||||
```yaml
|
||||
@@ -263,7 +338,17 @@ store the token as a secret in your repository and pass the new token to the [`a
|
||||
```
|
||||
You can learn more about Personal Access Token in the [GitHub documentation](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token).
|
||||
|
||||
Note: If you're working in an organisation and you don't want to create the PAT from your personal account, we recommend using a bot-account for such tokens.
|
||||
**Note:** If you're working in an organisation and you don't want to create the PAT from your personal account, we recommend using a bot-account for such tokens.
|
||||
|
||||
|
||||
If you go the "force pushes" route, you have to enable force pushes to a protected branch (See [documentation](https://help.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)) and update your Workflow to use force push like this.
|
||||
|
||||
```yaml
|
||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: Apply php-cs-fixer changes
|
||||
push_options: --force
|
||||
```
|
||||
|
||||
### No new workflows are triggered by the commit of this action
|
||||
|
||||
@@ -292,6 +377,14 @@ We use [SemVer](http://semver.org/) for versioning. For the versions available,
|
||||
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).)
|
||||
|
||||
## 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
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/LICENSE) file for details.
|
||||
|
17
action.yml
17
action.yml
@@ -16,6 +16,14 @@ 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`
|
||||
required: false
|
||||
@@ -52,10 +60,19 @@ 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
|
||||
disable_globbing:
|
||||
description: Stop the shell from expanding filenames (https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html)
|
||||
default: false
|
||||
|
||||
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.
|
||||
commit_hash:
|
||||
description: Full hash of the created commit. Only present if the "changes_detected" output is "true".
|
||||
|
||||
runs:
|
||||
using: 'node12'
|
||||
|
@@ -2,6 +2,10 @@
|
||||
|
||||
set -eu
|
||||
|
||||
if "$INPUT_DISABLE_GLOBBING"; then
|
||||
set -o noglob;
|
||||
fi
|
||||
|
||||
_main() {
|
||||
_switch_to_repository
|
||||
|
||||
@@ -33,8 +37,11 @@ _switch_to_repository() {
|
||||
}
|
||||
|
||||
_git_is_dirty() {
|
||||
echo "INPUT_STATUS_OPTIONS: ${INPUT_STATUS_OPTIONS}";
|
||||
echo "::debug::Apply status options ${INPUT_STATUS_OPTIONS}";
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
[ -n "$(git status -s -- $INPUT_FILE_PATTERN)" ]
|
||||
[ -n "$(git status -s $INPUT_STATUS_OPTIONS -- $INPUT_FILE_PATTERN)" ]
|
||||
}
|
||||
|
||||
_switch_to_branch() {
|
||||
@@ -48,16 +55,23 @@ _switch_to_branch() {
|
||||
git fetch --depth=1;
|
||||
fi
|
||||
|
||||
# Switch to branch from current Workflow run
|
||||
# shellcheck disable=SC2086
|
||||
git checkout $INPUT_BRANCH;
|
||||
if "$INPUT_SKIP_CHECKOUT"; then
|
||||
echo "::debug::git-checkout has not been executed";
|
||||
else
|
||||
# Switch to branch from current Workflow run
|
||||
# shellcheck disable=SC2086
|
||||
git checkout $INPUT_BRANCH --;
|
||||
fi
|
||||
}
|
||||
|
||||
_add_files() {
|
||||
echo "INPUT_ADD_OPTIONS: ${INPUT_ADD_OPTIONS}";
|
||||
echo "::debug::Apply add options ${INPUT_ADD_OPTIONS}";
|
||||
|
||||
echo "INPUT_FILE_PATTERN: ${INPUT_FILE_PATTERN}";
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
git add ${INPUT_FILE_PATTERN};
|
||||
git add ${INPUT_ADD_OPTIONS} ${INPUT_FILE_PATTERN};
|
||||
}
|
||||
|
||||
_local_commit() {
|
||||
@@ -76,6 +90,8 @@ _local_commit() {
|
||||
commit -m "$INPUT_COMMIT_MESSAGE" \
|
||||
--author="$INPUT_COMMIT_AUTHOR" \
|
||||
${INPUT_COMMIT_OPTIONS:+"${INPUT_COMMIT_OPTIONS_ARRAY[@]}"};
|
||||
|
||||
echo "::set-output name=commit_hash::$(git rev-parse HEAD)";
|
||||
}
|
||||
|
||||
_tag_commit() {
|
||||
@@ -104,7 +120,7 @@ _push_to_github() {
|
||||
if [ -n "$INPUT_TAGGING_MESSAGE" ]
|
||||
then
|
||||
echo "::debug::git push origin --tags";
|
||||
git push origin --tags ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
|
||||
git push origin --follow-tags --atomic ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
|
||||
else
|
||||
echo "::debug::git push origin";
|
||||
git push origin ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
|
||||
@@ -112,7 +128,7 @@ _push_to_github() {
|
||||
|
||||
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[@]}"};
|
||||
git push --set-upstream origin "HEAD:$INPUT_BRANCH" --follow-tags --atomic ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
|
||||
fi
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,8 @@ setup() {
|
||||
export INPUT_COMMIT_MESSAGE="Commit Message"
|
||||
export INPUT_BRANCH="master"
|
||||
export INPUT_COMMIT_OPTIONS=""
|
||||
export INPUT_ADD_OPTIONS=""
|
||||
export INPUT_STATUS_OPTIONS=""
|
||||
export INPUT_FILE_PATTERN="."
|
||||
export INPUT_COMMIT_USER_NAME="Test Suite"
|
||||
export INPUT_COMMIT_USER_EMAIL="test@github.com"
|
||||
@@ -22,8 +24,10 @@ setup() {
|
||||
export INPUT_PUSH_OPTIONS=""
|
||||
export INPUT_SKIP_DIRTY_CHECK=false
|
||||
export INPUT_SKIP_FETCH=false
|
||||
export INPUT_SKIP_CHECKOUT=false
|
||||
export INPUT_DISABLE_GLOBBING=false
|
||||
|
||||
# Configure Git
|
||||
# Configure Git
|
||||
if [[ -z $(git config user.name) ]]; then
|
||||
git config --global user.name "Test Suite"
|
||||
git config --global user.email "test@github.com"
|
||||
@@ -40,7 +44,7 @@ teardown() {
|
||||
rm -rf "${FAKE_TEMP_LOCAL_REPOSITORY}"
|
||||
}
|
||||
|
||||
# Create a fake remote repository which tests can push against
|
||||
# Create a fake remote repository which tests can push against
|
||||
_setup_fake_remote_repository() {
|
||||
# Create the bare repository, which will act as our remote/origin
|
||||
rm -rf "${FAKE_REMOTE}";
|
||||
@@ -69,7 +73,7 @@ _setup_local_repository() {
|
||||
cd "${FAKE_LOCAL_REPOSITORY}";
|
||||
}
|
||||
|
||||
# Run the main code related to this GitHub Action
|
||||
# Run the main code related to this GitHub Action
|
||||
git_auto_commit() {
|
||||
bash "${BATS_TEST_DIRNAME}"/../entrypoint.sh
|
||||
}
|
||||
@@ -83,6 +87,7 @@ git_auto_commit() {
|
||||
|
||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||
assert_line "::set-output name=changes_detected::true"
|
||||
assert_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
||||
assert_line "INPUT_BRANCH value: master"
|
||||
assert_line "INPUT_FILE_PATTERN: ."
|
||||
assert_line "INPUT_COMMIT_OPTIONS: "
|
||||
@@ -103,6 +108,7 @@ git_auto_commit() {
|
||||
|
||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||
assert_line "::set-output name=changes_detected::true"
|
||||
assert_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
||||
assert_line "INPUT_BRANCH value: master"
|
||||
assert_line "INPUT_FILE_PATTERN: ."
|
||||
assert_line "INPUT_COMMIT_OPTIONS: "
|
||||
@@ -114,6 +120,21 @@ git_auto_commit() {
|
||||
assert_line "::debug::Push commit to remote branch master"
|
||||
}
|
||||
|
||||
@test "It applies INPUT_STATUS_OPTIONS when running dirty check" {
|
||||
INPUT_STATUS_OPTIONS="--untracked-files=no"
|
||||
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2}.php
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_success
|
||||
|
||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||
assert_line "::set-output name=changes_detected::false"
|
||||
refute_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
||||
assert_line "Working tree clean. Nothing to commit."
|
||||
}
|
||||
|
||||
@test "It prints a 'Nothing to commit' message in a clean repository" {
|
||||
run git_auto_commit
|
||||
|
||||
@@ -121,6 +142,7 @@ git_auto_commit() {
|
||||
|
||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||
assert_line "::set-output name=changes_detected::false"
|
||||
refute_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
||||
assert_line "Working tree clean. Nothing to commit."
|
||||
}
|
||||
|
||||
@@ -133,14 +155,35 @@ git_auto_commit() {
|
||||
|
||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||
assert_line "::set-output name=changes_detected::true"
|
||||
|
||||
assert_line "::set-output name=changes_detected::true"
|
||||
refute_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
||||
assert_line "INPUT_BRANCH value: master"
|
||||
assert_line "INPUT_FILE_PATTERN: ."
|
||||
assert_line "INPUT_COMMIT_OPTIONS: "
|
||||
assert_line "::debug::Apply commit options "
|
||||
}
|
||||
|
||||
@test "It applies INPUT_ADD_OPTIONS when adding files" {
|
||||
INPUT_FILE_PATTERN=""
|
||||
INPUT_STATUS_OPTIONS="--untracked-files=no"
|
||||
INPUT_ADD_OPTIONS="-u"
|
||||
|
||||
date > "${FAKE_LOCAL_REPOSITORY}"/remote-files1.txt
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2}.php
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_success
|
||||
|
||||
assert_line "INPUT_STATUS_OPTIONS: --untracked-files=no"
|
||||
assert_line "INPUT_ADD_OPTIONS: -u"
|
||||
assert_line "INPUT_FILE_PATTERN: "
|
||||
assert_line "::debug::Push commit to remote branch master"
|
||||
|
||||
# Assert that PHP files have not been added.
|
||||
run git status
|
||||
assert_output --partial 'new-file-1.php'
|
||||
}
|
||||
|
||||
@test "It applies INPUT_FILE_PATTERN when creating commit" {
|
||||
INPUT_FILE_PATTERN="*.txt *.html"
|
||||
|
||||
@@ -225,6 +268,13 @@ git_auto_commit() {
|
||||
|
||||
run git ls-remote --tags --refs
|
||||
assert_output --partial refs/tags/v1.0.0
|
||||
|
||||
# Assert that the commit has been pushed with --force and
|
||||
# sha values are equal on local and remote
|
||||
current_sha="$(git rev-parse --verify --short master)"
|
||||
remote_sha="$(git rev-parse --verify --short origin/master)"
|
||||
|
||||
assert_equal $current_sha $remote_sha
|
||||
}
|
||||
|
||||
@test "It applies INPUT_PUSH_OPTIONS when pushing commit to remote" {
|
||||
@@ -257,7 +307,7 @@ git_auto_commit() {
|
||||
}
|
||||
|
||||
@test "It can checkout a different branch" {
|
||||
# Create foo-branch and then immediately switch back to master
|
||||
# Create foo-branch and then immediately switch back to master
|
||||
git checkout -b foo
|
||||
git checkout master
|
||||
|
||||
@@ -272,7 +322,7 @@ git_auto_commit() {
|
||||
assert_line "INPUT_BRANCH value: foo"
|
||||
assert_line "::debug::Push commit to remote branch foo"
|
||||
|
||||
# Assert a new branch "foo" exists on remote
|
||||
# Assert a new branch "foo" exists on remote
|
||||
run git ls-remote --heads
|
||||
assert_output --partial refs/heads/foo
|
||||
}
|
||||
@@ -331,3 +381,155 @@ git_auto_commit() {
|
||||
|
||||
assert_line "::debug::git-fetch has not been executed"
|
||||
}
|
||||
|
||||
@test "If SKIP_CHECKOUT is true git-checkout will not be called" {
|
||||
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
||||
|
||||
INPUT_SKIP_CHECKOUT=true
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_success
|
||||
|
||||
assert_line "::debug::git-checkout has not been executed"
|
||||
}
|
||||
|
||||
@test "It pushes generated commit and tag to remote and actually updates the commit shas" {
|
||||
INPUT_BRANCH=""
|
||||
INPUT_TAGGING_MESSAGE="v2.0.0"
|
||||
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_success
|
||||
|
||||
assert_line "INPUT_TAGGING_MESSAGE: v2.0.0"
|
||||
assert_line "::debug::Create tag v2.0.0"
|
||||
assert_line "::debug::git push origin --tags"
|
||||
|
||||
# Assert a tag v2.0.0 has been created
|
||||
run git tag
|
||||
assert_output v2.0.0
|
||||
|
||||
# Assert tag v2.0.0 has been pushed to remote
|
||||
run git ls-remote --tags --refs
|
||||
assert_output --partial refs/tags/v2.0.0
|
||||
|
||||
# Assert that branch "master" was updated on remote
|
||||
current_sha="$(git rev-parse --verify --short master)"
|
||||
remote_sha="$(git rev-parse --verify --short origin/master)"
|
||||
|
||||
assert_equal $current_sha $remote_sha
|
||||
}
|
||||
|
||||
@test "It pushes generated commit and tag to remote branch and updates commit sha" {
|
||||
# Create "a-new-branch"-branch and then immediately switch back to master
|
||||
git checkout -b a-new-branch
|
||||
git checkout master
|
||||
|
||||
INPUT_BRANCH="a-new-branch"
|
||||
INPUT_TAGGING_MESSAGE="v2.0.0"
|
||||
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_success
|
||||
|
||||
assert_line "INPUT_TAGGING_MESSAGE: v2.0.0"
|
||||
assert_line "::debug::Create tag v2.0.0"
|
||||
assert_line "::debug::Push commit to remote branch a-new-branch"
|
||||
|
||||
# Assert a tag v2.0.0 has been created
|
||||
run git tag
|
||||
assert_output v2.0.0
|
||||
|
||||
# Assert tag v2.0.0 has been pushed to remote
|
||||
run git ls-remote --tags --refs
|
||||
assert_output --partial refs/tags/v2.0.0
|
||||
|
||||
# Assert that branch "a-new-branch" was updated on remote
|
||||
current_sha="$(git rev-parse --verify --short a-new-branch)"
|
||||
remote_sha="$(git rev-parse --verify --short origin/a-new-branch)"
|
||||
|
||||
assert_equal $current_sha $remote_sha
|
||||
}
|
||||
|
||||
@test "It does not expand wildcard glob when using INPUT_PATTERN and INPUT_DISABLE_GLOBBING in git-status and git-add" {
|
||||
|
||||
# Create additional files in a nested directory structure
|
||||
echo "Create Additional files";
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-a.py
|
||||
mkdir "${FAKE_LOCAL_REPOSITORY}"/nested
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/nested/new-file-b.py
|
||||
|
||||
# Commit changes
|
||||
echo "Commit changes before running git_auto_commit";
|
||||
cd "${FAKE_LOCAL_REPOSITORY}";
|
||||
git add . > /dev/null;
|
||||
git commit --quiet -m "Init Remote Repository";
|
||||
git push origin master > /dev/null;
|
||||
|
||||
# Make nested file dirty
|
||||
echo "foo-bar" > "${FAKE_LOCAL_REPOSITORY}"/nested/new-file-b.py;
|
||||
|
||||
# ---
|
||||
|
||||
INPUT_FILE_PATTERN="*.py"
|
||||
INPUT_DISABLE_GLOBBING=true
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_success
|
||||
|
||||
assert_line "INPUT_FILE_PATTERN: *.py"
|
||||
assert_line "::debug::Push commit to remote branch master"
|
||||
|
||||
# Assert that the updated py file has been commited.
|
||||
run git status
|
||||
refute_output --partial 'nested/new-file-b.py'
|
||||
}
|
||||
|
||||
@test "it does not throw an error if not changes are detected and SKIP_DIRTY_CHECK is false" {
|
||||
INPUT_FILE_PATTERN="."
|
||||
INPUT_SKIP_DIRTY_CHECK=false
|
||||
INPUT_SKIP_FETCH=false
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_success
|
||||
|
||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||
assert_line "::set-output name=changes_detected::false"
|
||||
|
||||
run git status
|
||||
assert_output --partial 'nothing to commit, working tree clean'
|
||||
}
|
||||
|
||||
@test "It does not throw an error if branch is checked out with same name as a file or folder in the repo" {
|
||||
|
||||
# Add File called dev and commit/push
|
||||
echo "Create dev file";
|
||||
cd "${FAKE_LOCAL_REPOSITORY}";
|
||||
echo this is a file named dev > dev
|
||||
git add dev
|
||||
git commit -m 'add file named dev'
|
||||
git update-ref refs/remotes/origin/master master
|
||||
git update-ref refs/remotes/origin/dev master
|
||||
|
||||
# ---
|
||||
|
||||
INPUT_BRANCH=dev
|
||||
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{4,5,6}.txt
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_success
|
||||
|
||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||
assert_line "::set-output name=changes_detected::true"
|
||||
assert_line "::debug::Push commit to remote branch dev"
|
||||
}
|
||||
|
Reference in New Issue
Block a user