mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2025-08-01 07:56:08 +08:00
Compare commits
313 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
bbd291750d | ||
|
114a5e6044 | ||
|
4a75a2e723 | ||
|
1e826be61c | ||
|
4bab898d25 | ||
|
45872c3c23 | ||
|
9b7c21583c | ||
|
4cc90c7784 | ||
|
367938329d | ||
|
25cac34d8d | ||
|
30cd17bff0 | ||
|
8f5b58c89c | ||
|
65928d2898 | ||
|
6b4ef1444c | ||
|
55291ea168 | ||
|
2b5c86365b | ||
|
ff28943460 | ||
|
e3610414be | ||
|
042c3265d5 | ||
|
90cedba8bc | ||
|
b833fe0e9d | ||
|
653ea719ea | ||
|
47c724214a | ||
|
1ba48c6d7f | ||
|
b9e4cea0ef | ||
|
cfdb7e609e | ||
|
849613a3ad | ||
|
0ee9fb7263 | ||
|
6456430b6b | ||
|
7f67b0b49b | ||
|
8700c3bc1c | ||
|
872d72f1ae | ||
|
f905f00706 | ||
|
9c1e5d1c6a | ||
|
18a94e4f78 | ||
|
44aeb24da7 | ||
|
5c9bfe7477 | ||
|
814219db13 | ||
|
a204abce16 | ||
|
fc18df1417 | ||
|
8f243393e7 | ||
|
fc5b9bf8cf | ||
|
a818c89e49 | ||
|
8bf1b5695a | ||
|
ea30556d53 | ||
|
cd7c7f1a8a | ||
|
4e16840be4 | ||
|
b0295737db | ||
|
0d6d4a4b22 | ||
|
091b400419 | ||
|
f7e362220d | ||
|
df97d6fbd8 | ||
|
4f0fc14d0c | ||
|
cdf7b74cbf | ||
|
862aa0e1e1 | ||
|
a9d1ac4f06 | ||
|
ebf8a401ee | ||
|
4b8393320b | ||
|
60c96d8c0d | ||
|
16d2bf88fd | ||
|
54d78531cc | ||
|
f922a52bf1 | ||
|
0bf17c328a | ||
|
240b9ad1fd | ||
|
57054d8e7e | ||
|
613ea337db | ||
|
686020fb2a | ||
|
90b474f549 | ||
|
8c26230a11 | ||
|
961d68003e | ||
|
cbc3d50cea | ||
|
9e4e2e76fa | ||
|
09aaf2d8fa | ||
|
c7ad0bdb15 | ||
|
9cb711878d | ||
|
b3fc6f8a17 | ||
|
d51384f592 | ||
|
4e7ddef1e0 | ||
|
cc7755497c | ||
|
5c3c72f20e | ||
|
505389d146 | ||
|
303ce37181 | ||
|
13efc066dd | ||
|
3c204cdee3 | ||
|
0429047166 | ||
|
09d3315401 | ||
|
1f4914882d | ||
|
b5320678c1 | ||
|
01ffd8c6f6 | ||
|
5222c758dd | ||
|
bbcb72b1e9 | ||
|
142eb9509a | ||
|
0233fee872 | ||
|
808edcd96b | ||
|
1b1d53f462 | ||
|
ee93725e66 | ||
|
36304edfd2 | ||
|
ff97e958aa | ||
|
90282bf5e2 | ||
|
c9eb2132b2 | ||
|
c8ded2885e | ||
|
f120678ed1 | ||
|
4183594932 | ||
|
49e28abb3f | ||
|
4ebfe28af0 | ||
|
984a26d893 | ||
|
3804c79d2e | ||
|
69a12041a1 | ||
|
91b7d20ead | ||
|
044b6b777c | ||
|
9aab2f8a5c | ||
|
0280d2ccee | ||
|
b0b5ed34dd | ||
|
ae38c94802 | ||
|
3aae7bb63f | ||
|
c180c695f2 | ||
|
c1a70c9013 | ||
|
02c4f2cf78 | ||
|
3c687aa8ba | ||
|
a69eabaead | ||
|
9f2c45c9eb | ||
|
5bf88dc2fd | ||
|
fd2aab7c5b | ||
|
f342c95aa2 | ||
|
1157d7bbe9 | ||
|
58b79711d8 | ||
|
f5f76eb1f4 | ||
|
5513d18f64 | ||
|
6ef5688e81 | ||
|
e02ededdeb | ||
|
2f5e73df85 | ||
|
cc16347545 | ||
|
1ee136f439 | ||
|
7fdc480651 | ||
|
394681d465 | ||
|
a261484cc8 | ||
|
43ed630979 | ||
|
ee9d717e46 | ||
|
68b94ecdf3 | ||
|
2b0a9bca02 | ||
|
13c9c82cae | ||
|
6e0a745133 | ||
|
88ddd5fba5 | ||
|
2dec151b5c | ||
|
1ba0b8765f | ||
|
f278d451d8 | ||
|
1f6bf5e4c0 | ||
|
5dae7dbdb7 | ||
|
fbbf9665a8 | ||
|
e8ab63a01b | ||
|
fdbf836519 | ||
|
8f94f9b7ec | ||
|
e6db1ef8bd | ||
|
d09082150e | ||
|
3e578b5696 | ||
|
c586963a3d | ||
|
a7342eab13 | ||
|
256f31683d | ||
|
8040ba33d6 | ||
|
80c7ed953f | ||
|
dd055f6225 | ||
|
55734408b7 | ||
|
d317154f77 | ||
|
36489f4cb5 | ||
|
2530046e72 | ||
|
172c2a2fc3 | ||
|
480e111bf8 | ||
|
7659782c71 | ||
|
026f88c27c | ||
|
f73d11d461 | ||
|
2b6b90e8f1 | ||
|
e1770ec52b | ||
|
0453bb1c25 | ||
|
da55e4a0cf | ||
|
b1833bd054 | ||
|
6dfda22dd6 | ||
|
94c72aa7c5 | ||
|
87526a8aa1 | ||
|
844c808726 | ||
|
ce08dda6b3 | ||
|
0ad4c8ce73 | ||
|
3387b2f267 | ||
|
d4a53f1779 | ||
|
956a47433b | ||
|
f866b2a854 | ||
|
8744cc88ef | ||
|
57bbd38e56 | ||
|
eef5f33ea3 | ||
|
25e6f0b17d | ||
|
ae885f5d8c | ||
|
33e8fd937f | ||
|
404d2015f4 | ||
|
cd0530ad7a | ||
|
2a957f5c41 | ||
|
7e64e614a1 | ||
|
c887fa4a07 | ||
|
09d175379e | ||
|
cdb861eda0 | ||
|
6a853b60cc | ||
|
76f50fc3ad | ||
|
9b4acb8f10 | ||
|
d11ccd183d | ||
|
a156a1072e | ||
|
d69e5f0850 | ||
|
86f0c11c06 | ||
|
eda98fb9e5 | ||
|
844e852dde | ||
|
cca75e0840 | ||
|
ef107e1d4b | ||
|
e97d20ce65 | ||
|
3c9d7dd29d | ||
|
4ff392a586 | ||
|
69c53bd75e | ||
|
8563bc2c47 | ||
|
657dcb0873 | ||
|
1d39bb676c | ||
|
864c975b87 | ||
|
33592697c4 | ||
|
13e281008a | ||
|
42e5be9ebb | ||
|
f0354eba45 | ||
|
af7b14b2cf | ||
|
5a4e81ccd7 | ||
|
0884c39e7e | ||
|
5ab45a4eef | ||
|
e20b39e8ed | ||
|
5df30c89b8 | ||
|
b197c5ff8c | ||
|
098f1a8051 | ||
|
a06032e34f | ||
|
3185f2bd2a | ||
|
5432544bdb | ||
|
0a5fd7e510 | ||
|
81fa501ea5 | ||
|
3c60dc19b2 | ||
|
0822a9b930 | ||
|
d47024e59c | ||
|
ae384f95d0 | ||
|
959e7d4eab | ||
|
b21b1abc6d | ||
|
35440b9386 | ||
|
99f6ce74b4 | ||
|
4ab94c0ec4 | ||
|
1a9ba81dae | ||
|
2043118160 | ||
|
9879efa581 | ||
|
3525430c70 | ||
|
db25cb8fde | ||
|
5dd90bb58c | ||
|
36610a4da0 | ||
|
26a56d2023 | ||
|
6d7a33192e | ||
|
d625ec8b28 | ||
|
e870f94840 | ||
|
4a6ffd0603 | ||
|
dcfe3115ff | ||
|
3f6e990b1e | ||
|
560cf49647 | ||
|
c62363dd62 | ||
|
7c85ce3dee | ||
|
8bb153baaa | ||
|
68035425ff | ||
|
3273c330f8 | ||
|
4280601118 | ||
|
3c148f8a94 | ||
|
d3ceacae7d | ||
|
d338d7dd00 | ||
|
f7e2c0f118 | ||
|
8db04fa14f | ||
|
44a415d3cb | ||
|
af9e1689a5 | ||
|
2b22ba6212 | ||
|
b1b8ae8b5c | ||
|
fb3de05451 | ||
|
284d0b78f0 | ||
|
188fc2bd58 | ||
|
65d8bdf167 | ||
|
40255153c4 | ||
|
0ef5bf58dc | ||
|
e924b16154 | ||
|
2fb839c669 | ||
|
908446c002 | ||
|
2d23a29775 | ||
|
bdc88aff2c | ||
|
ddcd35eaa8 | ||
|
760c9be2dc | ||
|
69d0349561 | ||
|
eecee2898e | ||
|
3889fd6a6c | ||
|
1ad5315ba7 | ||
|
fa043bd474 | ||
|
af33cfbb5c | ||
|
677efa2969 | ||
|
b6dcf94303 | ||
|
a65a3a47cd | ||
|
a607c57aa4 | ||
|
134234c02d | ||
|
73ba09a90c | ||
|
92d05a9fc5 | ||
|
25c0d721b7 | ||
|
d6493da30b | ||
|
5de23163f2 | ||
|
16f4dc5956 | ||
|
03de600c97 | ||
|
40956d2dbd | ||
|
9fc8aa621f | ||
|
81c04ebd3c | ||
|
ef21fa22a3 | ||
|
e29ffba3a7 | ||
|
c1a88fc967 | ||
|
12d8aff89d | ||
|
62474225c7 | ||
|
b60aaac666 |
2
.github/FUNDING.yml
vendored
Normal file
2
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
github: stefanzweifel
|
||||||
|
custom: ["https://buymeacoff.ee/3oQ64YW"]
|
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
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.
|
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
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.
|
22
.github/workflows/git-auto-commit.yml
vendored
Normal file
22
.github/workflows/git-auto-commit.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: git-auto-commit
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
git-auto-commit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Use git-auto-commit-action
|
||||||
|
id: "auto-commit-action"
|
||||||
|
uses: ./
|
||||||
|
|
||||||
|
- name: "no changes detected"
|
||||||
|
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
|
||||||
|
run: "echo \"Changes detected\""
|
31
.github/workflows/integration-tests.yml
vendored
Normal file
31
.github/workflows/integration-tests.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
name: Integration Tests
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-commit-works:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: master
|
||||||
|
|
||||||
|
- name: Create Remote Branch
|
||||||
|
run: |
|
||||||
|
git checkout -b ci-test
|
||||||
|
git push origin ci-test
|
||||||
|
git checkout master
|
||||||
|
|
||||||
|
- name: Add Files
|
||||||
|
run: touch {a,b,c}.txt
|
||||||
|
|
||||||
|
- name: Run git-auto-commit
|
||||||
|
id: "auto-commit-action"
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
branch: ci-test
|
||||||
|
commit_message: Message
|
||||||
|
|
||||||
|
- name: Delete Branch
|
||||||
|
run: git push -d origin ci-test
|
19
.github/workflows/linter.yml
vendored
Normal file
19
.github/workflows/linter.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name: Lint Code Base
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Lint Code Base
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Lint Code Base
|
||||||
|
uses: github/super-linter@v3
|
||||||
|
env:
|
||||||
|
VALIDATE_ALL_CODEBASE: false
|
||||||
|
VALIDATE_MARKDOWN: false
|
||||||
|
DEFAULT_BRANCH: master
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
23
.github/workflows/tests.yml
vendored
Normal file
23
.github/workflows/tests.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: tests
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install Shell Mock
|
||||||
|
run: |
|
||||||
|
git clone https://github.com/capitalone/bash_shell_mock
|
||||||
|
cd bash_shell_mock
|
||||||
|
sudo ./install.sh /usr/local
|
||||||
|
|
||||||
|
- name: Install BATS
|
||||||
|
run: yarn install
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
run: yarn test
|
||||||
|
|
15
.github/workflows/versioning.yml
vendored
Normal file
15
.github/workflows/versioning.yml
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
name: Keep the versions up-to-date
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published, edited]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
actions-tagger:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: Actions-R-Us/actions-tagger@latest
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}"
|
||||||
|
with:
|
||||||
|
publish_latest_tag: true
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
tests/test_repo
|
||||||
|
tests/tmpstubs
|
||||||
|
tests/shellmock.*
|
||||||
|
yarn.lock
|
160
CHANGELOG.md
160
CHANGELOG.md
@@ -4,7 +4,165 @@ 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/)
|
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).
|
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/v2.1.0...HEAD)
|
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.7.2...HEAD)
|
||||||
|
|
||||||
|
> TBD
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
## [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/)
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
## [v2.1.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.0.0...v2.1.0) - 2019-09-20
|
## [v2.1.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.0.0...v2.1.0) - 2019-09-20
|
||||||
|
|
||||||
|
76
CODE_OF_CONDUCT.md
Normal file
76
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to making participation in our project and
|
||||||
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||||
|
level of experience, education, socio-economic status, nationality, personal
|
||||||
|
appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||||
|
advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic
|
||||||
|
address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable
|
||||||
|
behavior and are expected to take appropriate and fair corrective action in
|
||||||
|
response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or
|
||||||
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||||
|
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||||
|
permanently any contributor for other behaviors that they deem inappropriate,
|
||||||
|
threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces
|
||||||
|
when an individual is representing the project or its community. Examples of
|
||||||
|
representing a project or community include using an official project e-mail
|
||||||
|
address, posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event. Representation of a project may be
|
||||||
|
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
|
||||||
|
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.
|
||||||
|
Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||||
|
faith may face temporary or permanent repercussions as determined by other
|
||||||
|
members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||||
|
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see
|
||||||
|
https://www.contributor-covenant.org/faq
|
14
Dockerfile
14
Dockerfile
@@ -1,14 +0,0 @@
|
|||||||
FROM alpine/git:1.0.7
|
|
||||||
|
|
||||||
LABEL "com.github.actions.name"="Auto Commit changed files"
|
|
||||||
LABEL "com.github.actions.description"="Auotmatically commit changed files and push changes back to remote repository."
|
|
||||||
LABEL "com.github.actions.icon"="git-commit"
|
|
||||||
LABEL "com.github.actions.color"="orange"
|
|
||||||
|
|
||||||
LABEL "repository"="http://github.com/stefanzweifel/git-auto-commit-action"
|
|
||||||
LABEL "homepage"="http://github.com/stefanzweifel/git-auto-commit-action"
|
|
||||||
LABEL "maintainer"="Stefan Zweifel <hello@stefanzweifel.io>"
|
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["sh", "/entrypoint.sh"]
|
|
272
README.md
272
README.md
@@ -1,77 +1,275 @@
|
|||||||
# git-auto-commit-action
|
# git-auto-commit Action
|
||||||
|
|
||||||
This GitHub Action automatically commits files which have been changed during a Workflow run and pushes the Commit back to GitHub.
|
> The GitHub Action for committing files for the 80% use case.
|
||||||
The Committer is "GitHub Actions <actions@github.com>" and the Author of the Commit can be configured with input variables.
|
|
||||||
|
|
||||||
If no changes are available, the Actions does nothing.
|
<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>
|
||||||
|
<a href="https://github.com/stefanzweifel/git-auto-commit-action/actions?query=workflow%3A%22Integration+Tests%22">
|
||||||
|
<img src="https://github.com/stefanzweifel/git-auto-commit-action/workflows/Integration%20Tests/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.
|
||||||
|
The default committer is "GitHub Actions <actions@github.com>", and the default author of the commit is "Your GitHub Username <github_username@users.noreply.github.com>".
|
||||||
|
|
||||||
This Action has been inspired and adapted from the [auto-commit](https://github.com/cds-snc/github-actions/tree/master/auto-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 the [commit](https://github.com/elstudio/actions-js-build/blob/41d604d6e73d632e22eac40df8cc69b5added04b/commit/entrypoint.sh)-Action by Eric Johnson.
|
)-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.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Add the following step at the end of your job.
|
Add the following step at the end of your job, after other steps that might add or change files.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v2.0.0
|
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
with:
|
with:
|
||||||
|
# Optional but recommended, defaults to "Apply automatic changes"
|
||||||
commit_message: Apply automatic changes
|
commit_message: Apply automatic changes
|
||||||
branch: ${{ github.head_ref }}
|
|
||||||
env:
|
# Optional branch to push to, defaults to the current branch
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
branch: feature-123
|
||||||
|
|
||||||
|
# Optional options appended to `git-commit`
|
||||||
|
# See https://git-scm.com/docs/git-commit for a list of available options
|
||||||
|
commit_options: '--no-verify --signoff'
|
||||||
|
|
||||||
|
# Optional glob pattern of files which should be added to the commit
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Optional local file path to the repository
|
||||||
|
repository: .
|
||||||
|
|
||||||
|
# Optional commit user and author settings
|
||||||
|
commit_user_name: My GitHub Actions Bot
|
||||||
|
commit_user_email: my-github-actions-bot@example.org
|
||||||
|
commit_author: Author <actions@github.com>
|
||||||
|
|
||||||
|
# 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 options appended to `git-push`
|
||||||
|
# See git-push documentation for details: https://git-scm.com/docs/git-push#_options
|
||||||
|
push_options: '--force'
|
||||||
|
|
||||||
|
# Optional: Disable dirty check and always try to create a commit and push
|
||||||
|
skip_dirty_check: true
|
||||||
```
|
```
|
||||||
|
|
||||||
The Action will only commit files back, if changes are available. The resulting commit **will not trigger** another GitHub Actions Workflow run!
|
## Example
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
### Inputs
|
Note that we explicitly specify `${{ github.head_ref }}` in the checkout Action.
|
||||||
|
This is required in order to work with the `pull_request` event (or any other non-`push` event).
|
||||||
The following inputs are required
|
|
||||||
|
|
||||||
- `commit_message`: The commit message used when changes are available
|
|
||||||
- `branch`: Branch name where changes should be pushed to
|
|
||||||
|
|
||||||
### Environment Variables
|
|
||||||
|
|
||||||
The `GITHUB_TOKEN` secret is required. It is automatically available in your repository. You have to add it to the configuration though.
|
|
||||||
|
|
||||||
## Example Usage
|
|
||||||
|
|
||||||
This Action will only work, if the job in your workflow changes project files.
|
|
||||||
The most common use case for this, is when you're running a Linter or Code-Style fixer on GitHub Actions.
|
|
||||||
|
|
||||||
In this example I'm running `php-cs-fixer` in a PHP project.
|
|
||||||
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
on: push
|
|
||||||
name: php-cs-fixer
|
name: php-cs-fixer
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "main"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
php-cs-fixer:
|
php-cs-fixer:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
ref: ${{ github.head_ref }}
|
||||||
|
|
||||||
- name: Run php-cs-fixer
|
- name: Run php-cs-fixer
|
||||||
uses: docker://oskarstark/php-cs-fixer-ga
|
uses: docker://oskarstark/php-cs-fixer-ga
|
||||||
|
|
||||||
- name: Commit changed files
|
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
uses: stefanzweifel/git-auto-commit-action@v2.0.0
|
|
||||||
with:
|
with:
|
||||||
commit_message: Apply php-cs-fixer changes
|
commit_message: Apply php-cs-fixer changes
|
||||||
branch: ${{ github.head_ref }}
|
```
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
Checkout [`action.yml`](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/action.yml) for a full list of supported inputs.
|
||||||
|
|
||||||
|
## Outputs
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: "Run if changes have been detected"
|
||||||
|
if: steps.auto-commit-action.outputs.changes_detected == 'true'
|
||||||
|
run: echo "Changes!"
|
||||||
|
|
||||||
|
- name: "Run if no changes have been detected"
|
||||||
|
if: steps.auto-commit-action.outputs.changes_detected == 'false'
|
||||||
|
run: echo "No Changes!"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Limitations & Gotchas
|
||||||
|
|
||||||
|
### Checkout the correct branch
|
||||||
|
|
||||||
|
You must use `action/checkout@v2` or later versions to checkout the repository.
|
||||||
|
In non-`push` events, such as `pull_request`, make sure to specify the `ref` to checkout:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ github.head_ref }}
|
||||||
|
```
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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).
|
||||||
|
|
||||||
|
> 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.
|
||||||
|
|
||||||
|
You can change this by creating a new [Personal Access Token (PAT)](https://github.com/settings/tokens/new),
|
||||||
|
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
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
### Using the Action in forks from public repositories
|
||||||
|
|
||||||
|
**☝️ 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.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
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.)
|
||||||
|
|
||||||
|
If you want that a Workflow using this Action runs on Pull Requests opened by forks, 2 things have to be changed:
|
||||||
|
|
||||||
|
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!)
|
||||||
|
|
||||||
|
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**.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
#### 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.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Format PHP
|
||||||
|
|
||||||
|
on: [push, pull_request, pull_request_target]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
php-cs-fixer:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- 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
|
||||||
|
```
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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))
|
||||||
|
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
### Action does not push commit to repository
|
||||||
|
|
||||||
|
Make sure to [checkout the correct branch](#checkout-the-correct-branch).
|
||||||
|
|
||||||
|
### Action does not push commit to repository: Authentication Issue
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
|
||||||
|
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),
|
||||||
|
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).
|
||||||
|
|
||||||
|
## Running the tests
|
||||||
|
|
||||||
|
The package has tests written in [bats](https://github.com/bats-core/bats-core). You can run them with the following command.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
npm run test
|
||||||
```
|
```
|
||||||
|
|
||||||
## Versioning
|
## 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](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 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).)
|
||||||
|
|
||||||
## License
|
## 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.
|
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.
|
||||||
|
62
action.yml
Normal file
62
action.yml
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
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>
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
commit_message:
|
||||||
|
description: Commit message
|
||||||
|
required: false
|
||||||
|
default: Apply automatic changes
|
||||||
|
branch:
|
||||||
|
description: Git branch name, where changes should be pushed too. Required if Action is used on the `pull_request` event
|
||||||
|
required: false
|
||||||
|
default: ${{ github.head_ref }}
|
||||||
|
commit_options:
|
||||||
|
description: Commit options (eg. --no-verify)
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
file_pattern:
|
||||||
|
description: File pattern used for `git add`. For example `src/\*.js`
|
||||||
|
required: false
|
||||||
|
default: '.'
|
||||||
|
repository:
|
||||||
|
description: Local file path 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
|
||||||
|
commit_user_email:
|
||||||
|
description: Email address used for the commit user
|
||||||
|
required: false
|
||||||
|
default: actions@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>
|
||||||
|
tagging_message:
|
||||||
|
description: Message used to create a new git tag with the commit. Keep this empty, if no tag should be created.
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
push_options:
|
||||||
|
description: Push options (eg. --force)
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
skip_dirty_check:
|
||||||
|
description: Skip the check if the git repository is dirty and always try to create a commit.
|
||||||
|
required: false
|
||||||
|
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.
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: 'node12'
|
||||||
|
main: 'index.js'
|
||||||
|
|
||||||
|
branding:
|
||||||
|
icon: 'git-commit'
|
||||||
|
color: orange
|
20
actions.yml
20
actions.yml
@@ -1,20 +0,0 @@
|
|||||||
name: Git Auto Commit
|
|
||||||
description: 'Automatically commits files which have been changed.'
|
|
||||||
|
|
||||||
author: Stefan Zweifel <hello@stefanzweifel.io>
|
|
||||||
|
|
||||||
inputs:
|
|
||||||
commit_message:
|
|
||||||
description: Commit message
|
|
||||||
required: true
|
|
||||||
branch:
|
|
||||||
description: Branch where changes should be pushed too
|
|
||||||
required: true
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: 'docker'
|
|
||||||
image: 'Dockerfile'
|
|
||||||
|
|
||||||
branding:
|
|
||||||
icon: 'git-commit'
|
|
||||||
color: orange
|
|
121
entrypoint.sh
121
entrypoint.sh
@@ -1,40 +1,109 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# Set up .netrc file with GitHub credentials
|
_main() {
|
||||||
git_setup ( ) {
|
_switch_to_repository
|
||||||
cat <<- EOF > $HOME/.netrc
|
|
||||||
machine github.com
|
|
||||||
login $GITHUB_ACTOR
|
|
||||||
password $GITHUB_TOKEN
|
|
||||||
|
|
||||||
machine api.github.com
|
if _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then
|
||||||
login $GITHUB_ACTOR
|
|
||||||
password $GITHUB_TOKEN
|
|
||||||
EOF
|
|
||||||
chmod 600 $HOME/.netrc
|
|
||||||
|
|
||||||
git config --global user.email "actions@github.com"
|
echo "::set-output name=changes_detected::true";
|
||||||
git config --global user.name "GitHub Actions"
|
|
||||||
|
_switch_to_branch
|
||||||
|
|
||||||
|
_add_files
|
||||||
|
|
||||||
|
_local_commit
|
||||||
|
|
||||||
|
_tag_commit
|
||||||
|
|
||||||
|
_push_to_github
|
||||||
|
else
|
||||||
|
|
||||||
|
echo "::set-output name=changes_detected::false";
|
||||||
|
|
||||||
|
echo "Working tree clean. Nothing to commit.";
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# This section only runs if there have been file changes
|
_switch_to_repository() {
|
||||||
echo "Checking for uncommitted changes in the git working tree."
|
echo "INPUT_REPOSITORY value: $INPUT_REPOSITORY";
|
||||||
if ! git diff --quiet
|
cd "$INPUT_REPOSITORY";
|
||||||
then
|
}
|
||||||
git_setup
|
|
||||||
|
|
||||||
|
_git_is_dirty() {
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
[ -n "$(git status -s -- $INPUT_FILE_PATTERN)" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
_switch_to_branch() {
|
||||||
echo "INPUT_BRANCH value: $INPUT_BRANCH";
|
echo "INPUT_BRANCH value: $INPUT_BRANCH";
|
||||||
|
|
||||||
|
# Fetch remote to make sure that repo can be switched to the right branch.
|
||||||
|
git fetch;
|
||||||
|
|
||||||
# Switch to branch from current Workflow run
|
# Switch to branch from current Workflow run
|
||||||
git checkout $INPUT_BRANCH
|
# shellcheck disable=SC2086
|
||||||
|
git checkout $INPUT_BRANCH;
|
||||||
|
}
|
||||||
|
|
||||||
git add .
|
_add_files() {
|
||||||
|
echo "INPUT_FILE_PATTERN: ${INPUT_FILE_PATTERN}";
|
||||||
|
|
||||||
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>"
|
# shellcheck disable=SC2086
|
||||||
|
git add ${INPUT_FILE_PATTERN};
|
||||||
|
}
|
||||||
|
|
||||||
git push --set-upstream origin "HEAD:$INPUT_BRANCH"
|
_local_commit() {
|
||||||
else
|
echo "INPUT_COMMIT_OPTIONS: ${INPUT_COMMIT_OPTIONS}";
|
||||||
echo "Working tree clean. Nothing to commit."
|
echo "::debug::Apply commit options ${INPUT_COMMIT_OPTIONS}";
|
||||||
fi
|
|
||||||
|
# shellcheck disable=SC2206
|
||||||
|
INPUT_COMMIT_OPTIONS_ARRAY=( $INPUT_COMMIT_OPTIONS );
|
||||||
|
|
||||||
|
git -c user.name="$INPUT_COMMIT_USER_NAME" -c user.email="$INPUT_COMMIT_USER_EMAIL" \
|
||||||
|
commit -m "$INPUT_COMMIT_MESSAGE" \
|
||||||
|
--author="$INPUT_COMMIT_AUTHOR" \
|
||||||
|
${INPUT_COMMIT_OPTIONS:+"${INPUT_COMMIT_OPTIONS_ARRAY[@]}"};
|
||||||
|
}
|
||||||
|
|
||||||
|
_tag_commit() {
|
||||||
|
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";
|
||||||
|
else
|
||||||
|
echo "No tagging message supplied. No tag will be added.";
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_push_to_github() {
|
||||||
|
|
||||||
|
echo "INPUT_PUSH_OPTIONS: ${INPUT_PUSH_OPTIONS}";
|
||||||
|
echo "::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" ]
|
||||||
|
then
|
||||||
|
echo "::debug::git push origin --tags";
|
||||||
|
git push origin --tags ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
|
||||||
|
else
|
||||||
|
echo "::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[@]}"};
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_main
|
||||||
|
34
index.js
Normal file
34
index.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* Most of this code has been copied from the following GitHub Action
|
||||||
|
* to make it simpler or not necessary to install a lot of
|
||||||
|
* JavaScript packages to execute a shell script.
|
||||||
|
*
|
||||||
|
* https://github.com/ad-m/github-push-action/blob/fe38f0a751bf9149f0270cc1fe20bf9156854365/start.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
const spawn = require('child_process').spawn;
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const exec = (cmd, args=[]) => new Promise((resolve, reject) => {
|
||||||
|
console.log(`Started: ${cmd} ${args.join(" ")}`)
|
||||||
|
const app = spawn(cmd, args, { stdio: 'inherit' });
|
||||||
|
app.on('close', code => {
|
||||||
|
if(code !== 0){
|
||||||
|
err = new Error(`Invalid status code: ${code}`);
|
||||||
|
err.code = code;
|
||||||
|
return reject(err);
|
||||||
|
};
|
||||||
|
return resolve(code);
|
||||||
|
});
|
||||||
|
app.on('error', reject);
|
||||||
|
});
|
||||||
|
|
||||||
|
const main = async () => {
|
||||||
|
await exec('bash', [path.join(__dirname, './entrypoint.sh')]);
|
||||||
|
};
|
||||||
|
|
||||||
|
main().catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
console.error(err.stack);
|
||||||
|
process.exit(err.code || -1);
|
||||||
|
})
|
8
package.json
Normal file
8
package.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"devDependencies": {
|
||||||
|
"bats": "^1.1.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "rm -rf tests/tmpstubs && rm -rf tests/shellmock.* && bats tests"
|
||||||
|
}
|
||||||
|
}
|
439
tests/git-auto-commit-mocked.bats
Normal file
439
tests/git-auto-commit-mocked.bats
Normal file
@@ -0,0 +1,439 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
. shellmock
|
||||||
|
|
||||||
|
# Build World
|
||||||
|
export test_repository="${BATS_TEST_DIRNAME}/test_repo"
|
||||||
|
|
||||||
|
rm -rf "${test_repository}"
|
||||||
|
mkdir "${test_repository}"
|
||||||
|
touch "${test_repository}"/{a,b,c}.txt
|
||||||
|
cd "${test_repository}"
|
||||||
|
|
||||||
|
git init --quiet
|
||||||
|
git add . > /dev/null 2>&1
|
||||||
|
|
||||||
|
if [[ -z $(git config user.name) ]]; then
|
||||||
|
git config --global user.email "test@github.com"
|
||||||
|
git config --global user.name "Test Suite"
|
||||||
|
fi
|
||||||
|
|
||||||
|
git commit --quiet -m "Init Repo"
|
||||||
|
|
||||||
|
# Set default INPUT variables
|
||||||
|
export INPUT_REPOSITORY="${BATS_TEST_DIRNAME}/test_repo"
|
||||||
|
export INPUT_COMMIT_MESSAGE="Commit Message"
|
||||||
|
export INPUT_BRANCH="master"
|
||||||
|
export INPUT_COMMIT_OPTIONS=""
|
||||||
|
export INPUT_FILE_PATTERN="."
|
||||||
|
export INPUT_COMMIT_USER_NAME="Test Suite"
|
||||||
|
export INPUT_COMMIT_USER_EMAIL="test@github.com"
|
||||||
|
export INPUT_COMMIT_AUTHOR="Test Suite <test@users.noreply.github.com>"
|
||||||
|
export INPUT_TAGGING_MESSAGE=""
|
||||||
|
export INPUT_PUSH_OPTIONS=""
|
||||||
|
export INPUT_SKIP_DIRTY_CHECK=false
|
||||||
|
|
||||||
|
skipIfNot "$BATS_TEST_DESCRIPTION"
|
||||||
|
|
||||||
|
if [ -z "$TEST_FUNCTION" ]; then
|
||||||
|
shellmock_clean
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
|
||||||
|
if [ -z "$TEST_FUNCTION" ]; then
|
||||||
|
shellmock_clean
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "${test_repository}"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
bash "${BATS_TEST_DIRNAME}"/../entrypoint.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@test "clean-repo-prints-nothing-to-commit-message" {
|
||||||
|
|
||||||
|
run main
|
||||||
|
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "${lines[0]}" = "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}" ]
|
||||||
|
[ "${lines[1]}" = "::set-output name=changes_detected::false" ]
|
||||||
|
[ "${lines[2]}" = "Working tree clean. Nothing to commit." ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "commit-changed-files-and-push-to-remote" {
|
||||||
|
|
||||||
|
touch "${test_repository}"/new-file-{1,2,3}.txt
|
||||||
|
|
||||||
|
shellmock_expect git --type partial --output " M new-file-1.txt M new-file-2.txt M new-file-3.txt" --match "status"
|
||||||
|
shellmock_expect git --type exact --match "fetch"
|
||||||
|
shellmock_expect git --type exact --match "checkout master"
|
||||||
|
shellmock_expect git --type partial --match "add ."
|
||||||
|
shellmock_expect git --type partial --match '-c'
|
||||||
|
shellmock_expect git --type partial --match 'push --set-upstream origin'
|
||||||
|
|
||||||
|
run main
|
||||||
|
|
||||||
|
echo "$output"
|
||||||
|
|
||||||
|
# Success Exit Code
|
||||||
|
[ "$status" = 0 ]
|
||||||
|
|
||||||
|
[ "${lines[0]}" = "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}" ]
|
||||||
|
[ "${lines[1]}" = "::set-output name=changes_detected::true" ]
|
||||||
|
[ "${lines[2]}" = "INPUT_BRANCH value: master" ]
|
||||||
|
[ "${lines[3]}" = "INPUT_FILE_PATTERN: ." ]
|
||||||
|
[ "${lines[4]}" = "INPUT_COMMIT_OPTIONS: " ]
|
||||||
|
[ "${lines[5]}" = "::debug::Apply commit options " ]
|
||||||
|
[ "${lines[6]}" = "INPUT_TAGGING_MESSAGE: " ]
|
||||||
|
[ "${lines[7]}" = "No tagging message supplied. No tag will be added." ]
|
||||||
|
[ "${lines[8]}" = "INPUT_PUSH_OPTIONS: " ]
|
||||||
|
[ "${lines[9]}" = "::debug::Apply push options " ]
|
||||||
|
[ "${lines[10]}" = "::debug::Push commit to remote branch master" ]
|
||||||
|
|
||||||
|
|
||||||
|
shellmock_verify
|
||||||
|
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||||
|
[ "${capture[1]}" = "git-stub fetch" ]
|
||||||
|
[ "${capture[2]}" = "git-stub checkout master" ]
|
||||||
|
[ "${capture[3]}" = "git-stub add ." ]
|
||||||
|
[ "${capture[4]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com commit -m Commit Message --author=Test Suite <test@users.noreply.github.com>" ]
|
||||||
|
[ "${capture[5]}" = "git-stub push --set-upstream origin HEAD:master --tags" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "skip-dirty-on-clean-repo-failure" {
|
||||||
|
|
||||||
|
INPUT_SKIP_DIRTY_CHECK=true
|
||||||
|
|
||||||
|
shellmock_expect git --type exact --match "status -s ."
|
||||||
|
shellmock_expect git --type exact --match "fetch"
|
||||||
|
shellmock_expect git --type exact --match "checkout master"
|
||||||
|
shellmock_expect git --type exact --match "add ."
|
||||||
|
shellmock_expect git --type partial --match '-c'
|
||||||
|
shellmock_expect git --type partial --match 'push origin'
|
||||||
|
|
||||||
|
run main
|
||||||
|
|
||||||
|
echo "$output"
|
||||||
|
|
||||||
|
shellmock_verify
|
||||||
|
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||||
|
[ "${capture[1]}" = "git-stub fetch" ]
|
||||||
|
[ "${capture[2]}" = "git-stub checkout master" ]
|
||||||
|
[ "${capture[3]}" = "git-stub add ." ]
|
||||||
|
[ "${capture[4]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com commit -m Commit Message --author=Test Suite <test@users.noreply.github.com>" ]
|
||||||
|
[ "${capture[5]}" = "git-stub push --set-upstream origin HEAD:master --tags" ]
|
||||||
|
|
||||||
|
# Failed Exit Code
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
|
||||||
|
[ "${lines[0]}" = "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}" ]
|
||||||
|
[ "${lines[1]}" = "::set-output name=changes_detected::true" ]
|
||||||
|
[ "${lines[2]}" = "INPUT_BRANCH value: master" ]
|
||||||
|
[ "${lines[3]}" = "INPUT_FILE_PATTERN: ." ]
|
||||||
|
[ "${lines[4]}" = "INPUT_COMMIT_OPTIONS: " ]
|
||||||
|
[ "${lines[5]}" = "::debug::Apply commit options " ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "git-add-file-pattern-is-applied" {
|
||||||
|
|
||||||
|
INPUT_FILE_PATTERN="*.txt *.html"
|
||||||
|
|
||||||
|
touch "${test_repository}"/new-file-{1,2}.php
|
||||||
|
touch "${test_repository}"/new-file-{1,2}.html
|
||||||
|
|
||||||
|
shellmock_expect git --type partial --output " M new-file-1.html M new-file-2.html" --match "status"
|
||||||
|
shellmock_expect git --type exact --match "fetch"
|
||||||
|
shellmock_expect git --type exact --match "checkout master"
|
||||||
|
shellmock_expect git --type partial --match "add"
|
||||||
|
shellmock_expect git --type partial --match '-c'
|
||||||
|
shellmock_expect git --type partial --match 'push --set-upstream origin'
|
||||||
|
|
||||||
|
run main
|
||||||
|
|
||||||
|
echo "$output"
|
||||||
|
|
||||||
|
# Success Exit Code
|
||||||
|
[ "$status" = 0 ]
|
||||||
|
|
||||||
|
[ "${lines[3]}" = "INPUT_FILE_PATTERN: *.txt *.html" ]
|
||||||
|
[ "${lines[10]}" = "::debug::Push commit to remote branch master" ]
|
||||||
|
|
||||||
|
|
||||||
|
shellmock_verify
|
||||||
|
[ "${capture[0]}" = "git-stub status -s -- a.txt b.txt c.txt new-file-1.html new-file-2.html" ]
|
||||||
|
[ "${capture[1]}" = "git-stub fetch" ]
|
||||||
|
[ "${capture[2]}" = "git-stub checkout master" ]
|
||||||
|
[ "${capture[3]}" = "git-stub add a.txt b.txt c.txt new-file-1.html new-file-2.html" ]
|
||||||
|
[ "${capture[4]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com commit -m Commit Message --author=Test Suite <test@users.noreply.github.com>" ]
|
||||||
|
[ "${capture[5]}" = "git-stub push --set-upstream origin HEAD:master --tags" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "git-commit-options-are-applied" {
|
||||||
|
|
||||||
|
INPUT_COMMIT_OPTIONS="--no-verify --signoff"
|
||||||
|
|
||||||
|
touch "${test_repository}"/new-file-{1,2}.txt
|
||||||
|
|
||||||
|
shellmock_expect git --type partial --output " M new-file-1.txt M new-file-2.txt" --match "status"
|
||||||
|
shellmock_expect git --type exact --match "fetch"
|
||||||
|
shellmock_expect git --type exact --match "checkout master"
|
||||||
|
shellmock_expect git --type partial --match "add"
|
||||||
|
shellmock_expect git --type partial --match '-c'
|
||||||
|
shellmock_expect git --type partial --match 'push --set-upstream origin'
|
||||||
|
|
||||||
|
run main
|
||||||
|
|
||||||
|
echo "$output"
|
||||||
|
|
||||||
|
# Success Exit Code
|
||||||
|
[ "$status" = 0 ]
|
||||||
|
[ "${lines[4]}" = "INPUT_COMMIT_OPTIONS: --no-verify --signoff" ]
|
||||||
|
[ "${lines[10]}" = "::debug::Push commit to remote branch master" ]
|
||||||
|
|
||||||
|
shellmock_verify
|
||||||
|
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||||
|
[ "${capture[1]}" = "git-stub fetch" ]
|
||||||
|
[ "${capture[2]}" = "git-stub checkout master" ]
|
||||||
|
[ "${capture[3]}" = "git-stub add ." ]
|
||||||
|
[ "${capture[4]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com commit -m Commit Message --author=Test Suite <test@users.noreply.github.com> --no-verify --signoff" ]
|
||||||
|
[ "${capture[5]}" = "git-stub push --set-upstream origin HEAD:master --tags" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "commit-user-and-author-settings-are-applied" {
|
||||||
|
|
||||||
|
INPUT_COMMIT_USER_NAME="A Single Test"
|
||||||
|
INPUT_COMMIT_USER_EMAIL="single-test@github.com"
|
||||||
|
INPUT_COMMIT_AUTHOR="A Single Test <single@users.noreply.github.com>"
|
||||||
|
|
||||||
|
touch "${test_repository}"/new-file-{1,2}.txt
|
||||||
|
|
||||||
|
shellmock_expect git --type partial --output " M new-file-1.txt M new-file-2.txt" --match "status"
|
||||||
|
shellmock_expect git --type exact --match "fetch"
|
||||||
|
shellmock_expect git --type exact --match "checkout master"
|
||||||
|
shellmock_expect git --type partial --match "add"
|
||||||
|
shellmock_expect git --type partial --match '-c'
|
||||||
|
shellmock_expect git --type partial --match 'push --set-upstream origin'
|
||||||
|
|
||||||
|
run main
|
||||||
|
|
||||||
|
echo "$output"
|
||||||
|
|
||||||
|
# Success Exit Code
|
||||||
|
[ "$status" = 0 ]
|
||||||
|
|
||||||
|
[ "${lines[10]}" = "::debug::Push commit to remote branch master" ]
|
||||||
|
|
||||||
|
shellmock_verify
|
||||||
|
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||||
|
[ "${capture[1]}" = "git-stub fetch" ]
|
||||||
|
[ "${capture[2]}" = "git-stub checkout master" ]
|
||||||
|
[ "${capture[3]}" = "git-stub add ." ]
|
||||||
|
[ "${capture[4]}" = "git-stub -c user.name=A Single Test -c user.email=single-test@github.com commit -m Commit Message --author=A Single Test <single@users.noreply.github.com>" ]
|
||||||
|
[ "${capture[5]}" = "git-stub push --set-upstream origin HEAD:master --tags" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "can-create-tag" {
|
||||||
|
|
||||||
|
INPUT_TAGGING_MESSAGE="v1.0.0"
|
||||||
|
|
||||||
|
touch "${test_repository}"/new-file-{1,2,3}.txt
|
||||||
|
|
||||||
|
shellmock_expect git --type partial --output " M new-file-1.txt M new-file-2.txt M new-file-3.txt" --match "status"
|
||||||
|
shellmock_expect git --type exact --match "fetch"
|
||||||
|
shellmock_expect git --type exact --match "checkout master"
|
||||||
|
shellmock_expect git --type partial --match "add ."
|
||||||
|
shellmock_expect git --type partial --match '-c'
|
||||||
|
shellmock_expect git --type partial --match 'push --set-upstream origin'
|
||||||
|
|
||||||
|
run main
|
||||||
|
|
||||||
|
echo "$output"
|
||||||
|
|
||||||
|
# Success Exit Code
|
||||||
|
[ "$status" = 0 ]
|
||||||
|
|
||||||
|
[ "${lines[6]}" = "INPUT_TAGGING_MESSAGE: v1.0.0" ]
|
||||||
|
[ "${lines[7]}" = "::debug::Create tag v1.0.0" ]
|
||||||
|
[ "${lines[10]}" = "::debug::Push commit to remote branch master" ]
|
||||||
|
|
||||||
|
|
||||||
|
shellmock_verify
|
||||||
|
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||||
|
[ "${capture[1]}" = "git-stub fetch" ]
|
||||||
|
[ "${capture[2]}" = "git-stub checkout master" ]
|
||||||
|
[ "${capture[3]}" = "git-stub add ." ]
|
||||||
|
[ "${capture[4]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com commit -m Commit Message --author=Test Suite <test@users.noreply.github.com>" ]
|
||||||
|
[ "${capture[5]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com tag -a v1.0.0 -m v1.0.0" ]
|
||||||
|
[ "${capture[6]}" = "git-stub push --set-upstream origin HEAD:master --tags" ]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "git-push-options-are-applied" {
|
||||||
|
|
||||||
|
INPUT_PUSH_OPTIONS="--force"
|
||||||
|
|
||||||
|
touch "${test_repository}"/new-file-{1,2,3}.txt
|
||||||
|
|
||||||
|
shellmock_expect git --type partial --output " M new-file-1.txt M new-file-2.txt M new-file-3.txt" --match "status"
|
||||||
|
shellmock_expect git --type exact --match "fetch"
|
||||||
|
shellmock_expect git --type exact --match "checkout master"
|
||||||
|
shellmock_expect git --type partial --match "add ."
|
||||||
|
shellmock_expect git --type partial --match '-c'
|
||||||
|
shellmock_expect git --type partial --match 'push --set-upstream origin'
|
||||||
|
|
||||||
|
run main
|
||||||
|
|
||||||
|
echo "$output"
|
||||||
|
|
||||||
|
# Success Exit Code
|
||||||
|
[ "$status" = 0 ]
|
||||||
|
|
||||||
|
[ "${lines[8]}" = "INPUT_PUSH_OPTIONS: --force" ]
|
||||||
|
[ "${lines[9]}" = "::debug::Apply push options --force" ]
|
||||||
|
[ "${lines[10]}" = "::debug::Push commit to remote branch master" ]
|
||||||
|
|
||||||
|
|
||||||
|
shellmock_verify
|
||||||
|
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||||
|
[ "${capture[1]}" = "git-stub fetch" ]
|
||||||
|
[ "${capture[2]}" = "git-stub checkout master" ]
|
||||||
|
[ "${capture[3]}" = "git-stub add ." ]
|
||||||
|
[ "${capture[4]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com commit -m Commit Message --author=Test Suite <test@users.noreply.github.com>" ]
|
||||||
|
[ "${capture[5]}" = "git-stub push --set-upstream origin HEAD:master --tags --force" ]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "can-checkout-different-branch" {
|
||||||
|
|
||||||
|
INPUT_BRANCH="foo"
|
||||||
|
|
||||||
|
touch "${test_repository}"/new-file-{1,2,3}.txt
|
||||||
|
|
||||||
|
shellmock_expect git --type partial --output " M new-file-1.txt M new-file-2.txt M new-file-3.txt" --match "status"
|
||||||
|
shellmock_expect git --type exact --match "fetch"
|
||||||
|
shellmock_expect git --type exact --match "checkout foo"
|
||||||
|
shellmock_expect git --type partial --match "add ."
|
||||||
|
shellmock_expect git --type partial --match '-c'
|
||||||
|
shellmock_expect git --type partial --match 'push --set-upstream origin'
|
||||||
|
|
||||||
|
run main
|
||||||
|
|
||||||
|
echo "$output"
|
||||||
|
|
||||||
|
# Success Exit Code
|
||||||
|
[ "$status" = 0 ]
|
||||||
|
|
||||||
|
[ "${lines[0]}" = "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}" ]
|
||||||
|
[ "${lines[1]}" = "::set-output name=changes_detected::true" ]
|
||||||
|
[ "${lines[2]}" = "INPUT_BRANCH value: foo" ]
|
||||||
|
[ "${lines[3]}" = "INPUT_FILE_PATTERN: ." ]
|
||||||
|
[ "${lines[4]}" = "INPUT_COMMIT_OPTIONS: " ]
|
||||||
|
[ "${lines[5]}" = "::debug::Apply commit options " ]
|
||||||
|
[ "${lines[6]}" = "INPUT_TAGGING_MESSAGE: " ]
|
||||||
|
[ "${lines[7]}" = "No tagging message supplied. No tag will be added." ]
|
||||||
|
[ "${lines[8]}" = "INPUT_PUSH_OPTIONS: " ]
|
||||||
|
[ "${lines[9]}" = "::debug::Apply push options " ]
|
||||||
|
[ "${lines[10]}" = "::debug::Push commit to remote branch foo" ]
|
||||||
|
|
||||||
|
|
||||||
|
shellmock_verify
|
||||||
|
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||||
|
[ "${capture[1]}" = "git-stub fetch" ]
|
||||||
|
[ "${capture[2]}" = "git-stub checkout foo" ]
|
||||||
|
[ "${capture[3]}" = "git-stub add ." ]
|
||||||
|
[ "${capture[4]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com commit -m Commit Message --author=Test Suite <test@users.noreply.github.com>" ]
|
||||||
|
[ "${capture[5]}" = "git-stub push --set-upstream origin HEAD:foo --tags" ]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "can-work-with-empty-branch-name" {
|
||||||
|
|
||||||
|
INPUT_BRANCH=""
|
||||||
|
|
||||||
|
touch "${test_repository}"/new-file-{1,2,3}.txt
|
||||||
|
|
||||||
|
shellmock_expect git --type partial --output " M new-file-1.txt M new-file-2.txt M new-file-3.txt" --match "status"
|
||||||
|
shellmock_expect git --type exact --match "fetch"
|
||||||
|
shellmock_expect git --type exact --match "checkout"
|
||||||
|
shellmock_expect git --type partial --match "add ."
|
||||||
|
shellmock_expect git --type partial --match '-c'
|
||||||
|
shellmock_expect git --type partial --match 'push origin'
|
||||||
|
|
||||||
|
run main
|
||||||
|
|
||||||
|
echo "$output"
|
||||||
|
|
||||||
|
# Success Exit Code
|
||||||
|
[ "$status" = 0 ]
|
||||||
|
|
||||||
|
[ "${lines[0]}" = "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}" ]
|
||||||
|
[ "${lines[1]}" = "::set-output name=changes_detected::true" ]
|
||||||
|
[ "${lines[2]}" = "INPUT_BRANCH value: " ]
|
||||||
|
[ "${lines[3]}" = "INPUT_FILE_PATTERN: ." ]
|
||||||
|
[ "${lines[4]}" = "INPUT_COMMIT_OPTIONS: " ]
|
||||||
|
[ "${lines[5]}" = "::debug::Apply commit options " ]
|
||||||
|
[ "${lines[6]}" = "INPUT_TAGGING_MESSAGE: " ]
|
||||||
|
[ "${lines[7]}" = "No tagging message supplied. No tag will be added." ]
|
||||||
|
[ "${lines[8]}" = "INPUT_PUSH_OPTIONS: " ]
|
||||||
|
[ "${lines[9]}" = "::debug::Apply push options " ]
|
||||||
|
[ "${lines[10]}" = "::debug::git push origin" ]
|
||||||
|
|
||||||
|
|
||||||
|
shellmock_verify
|
||||||
|
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||||
|
[ "${capture[1]}" = "git-stub fetch" ]
|
||||||
|
[ "${capture[2]}" = "git-stub checkout" ]
|
||||||
|
[ "${capture[3]}" = "git-stub add ." ]
|
||||||
|
[ "${capture[4]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com commit -m Commit Message --author=Test Suite <test@users.noreply.github.com>" ]
|
||||||
|
[ "${capture[5]}" = "git-stub push origin" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "can-work-with-empty-branch-name-and-tags" {
|
||||||
|
|
||||||
|
INPUT_BRANCH=""
|
||||||
|
INPUT_TAGGING_MESSAGE="v2.0.0"
|
||||||
|
|
||||||
|
touch "${test_repository}"/new-file-{1,2,3}.txt
|
||||||
|
|
||||||
|
shellmock_expect git --type partial --output " M new-file-1.txt M new-file-2.txt M new-file-3.txt" --match "status"
|
||||||
|
shellmock_expect git --type exact --match "fetch"
|
||||||
|
shellmock_expect git --type exact --match "checkout"
|
||||||
|
shellmock_expect git --type partial --match "add ."
|
||||||
|
shellmock_expect git --type partial --match '-c'
|
||||||
|
shellmock_expect git --type partial --match 'push origin'
|
||||||
|
|
||||||
|
run main
|
||||||
|
|
||||||
|
echo "$output"
|
||||||
|
|
||||||
|
# Success Exit Code
|
||||||
|
[ "$status" = 0 ]
|
||||||
|
|
||||||
|
[ "${lines[0]}" = "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}" ]
|
||||||
|
[ "${lines[1]}" = "::set-output name=changes_detected::true" ]
|
||||||
|
[ "${lines[2]}" = "INPUT_BRANCH value: " ]
|
||||||
|
[ "${lines[3]}" = "INPUT_FILE_PATTERN: ." ]
|
||||||
|
[ "${lines[4]}" = "INPUT_COMMIT_OPTIONS: " ]
|
||||||
|
[ "${lines[5]}" = "::debug::Apply commit options " ]
|
||||||
|
[ "${lines[6]}" = "INPUT_TAGGING_MESSAGE: v2.0.0" ]
|
||||||
|
[ "${lines[7]}" = "::debug::Create tag v2.0.0" ]
|
||||||
|
[ "${lines[8]}" = "INPUT_PUSH_OPTIONS: " ]
|
||||||
|
[ "${lines[9]}" = "::debug::Apply push options " ]
|
||||||
|
[ "${lines[10]}" = "::debug::git push origin --tags" ]
|
||||||
|
|
||||||
|
|
||||||
|
shellmock_verify
|
||||||
|
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||||
|
[ "${capture[1]}" = "git-stub fetch" ]
|
||||||
|
[ "${capture[2]}" = "git-stub checkout" ]
|
||||||
|
[ "${capture[3]}" = "git-stub add ." ]
|
||||||
|
[ "${capture[4]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com commit -m Commit Message --author=Test Suite <test@users.noreply.github.com>" ]
|
||||||
|
[ "${capture[5]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com tag -a v2.0.0 -m v2.0.0" ]
|
||||||
|
[ "${capture[6]}" = "git-stub push origin --tags" ]
|
||||||
|
|
||||||
|
}
|
8
yarn.lock
Normal file
8
yarn.lock
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
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==
|
Reference in New Issue
Block a user