mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2025-07-31 15:26:10 +08:00
Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
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 |
26
.github/workflows/integration-tests.yml
vendored
Normal file
26
.github/workflows/integration-tests.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
name: Integration Tests
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
test-commit-works:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: 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
|
||||
checkout_options: -b
|
||||
|
||||
- name: Delete Branch
|
||||
run: git push -d origin ci-test
|
1
.github/workflows/linter.yml
vendored
1
.github/workflows/linter.yml
vendored
@@ -14,5 +14,6 @@ jobs:
|
||||
uses: github/super-linter@v3
|
||||
env:
|
||||
VALIDATE_ALL_CODEBASE: false
|
||||
VALIDATE_MARKDOWN: false
|
||||
DEFAULT_BRANCH: master
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
17
CHANGELOG.md
17
CHANGELOG.md
@@ -4,15 +4,26 @@ 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.6.0...HEAD)
|
||||
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.7.1...HEAD)
|
||||
|
||||
> TBD
|
||||
|
||||
|
||||
## [v4.7.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.7.0...v4.7.1) - 2020-10-12
|
||||
|
||||
### 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-11
|
||||
|
||||
### 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
|
||||
|
||||
### Changes
|
||||
|
||||
### 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
|
||||
|
16
README.md
16
README.md
@@ -5,6 +5,9 @@
|
||||
<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>".
|
||||
@@ -146,6 +149,11 @@ If you work in an organization and don't want to create a PAT from your personal
|
||||
|
||||
### 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:
|
||||
@@ -165,15 +173,13 @@ The following workflow runs `php-cs-fixer` (a code linter and fixer for PHP) whe
|
||||
```yaml
|
||||
name: Format PHP
|
||||
|
||||
on: [pull_request, pull_request_target]
|
||||
on: [push, pull_request, pull_request_target]
|
||||
|
||||
jobs:
|
||||
php-cs-fixer:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
- name: Run php-cs-fixer
|
||||
uses: docker://oskarstark/php-cs-fixer-ga
|
||||
@@ -190,7 +196,7 @@ 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 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/).
|
||||
@@ -254,7 +260,7 @@ This is due to limitations set up by GitHub, [commits of this Action do not trig
|
||||
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 tests
|
||||
npm run test
|
||||
```
|
||||
|
||||
## Versioning
|
||||
|
@@ -29,10 +29,11 @@ _main() {
|
||||
|
||||
_switch_to_repository() {
|
||||
echo "INPUT_REPOSITORY value: $INPUT_REPOSITORY";
|
||||
cd $INPUT_REPOSITORY;
|
||||
cd "$INPUT_REPOSITORY";
|
||||
}
|
||||
|
||||
_git_is_dirty() {
|
||||
# shellcheck disable=SC2086
|
||||
[ -n "$(git status -s -- $INPUT_FILE_PATTERN)" ]
|
||||
}
|
||||
|
||||
@@ -43,11 +44,13 @@ _switch_to_branch() {
|
||||
git fetch;
|
||||
|
||||
# Switch to branch from current Workflow run
|
||||
git checkout $INPUT_BRANCH;
|
||||
git checkout "$INPUT_BRANCH" --;
|
||||
}
|
||||
|
||||
_add_files() {
|
||||
echo "INPUT_FILE_PATTERN: ${INPUT_FILE_PATTERN}";
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
git add ${INPUT_FILE_PATTERN};
|
||||
}
|
||||
|
||||
@@ -55,6 +58,7 @@ _local_commit() {
|
||||
echo "INPUT_COMMIT_OPTIONS: ${INPUT_COMMIT_OPTIONS}";
|
||||
echo "::debug::Apply commit options ${INPUT_COMMIT_OPTIONS}";
|
||||
|
||||
# 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" \
|
||||
@@ -80,6 +84,7 @@ _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" ]
|
||||
|
@@ -71,7 +71,7 @@ main() {
|
||||
|
||||
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 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'
|
||||
@@ -99,7 +99,7 @@ main() {
|
||||
shellmock_verify
|
||||
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||
[ "${capture[1]}" = "git-stub fetch" ]
|
||||
[ "${capture[2]}" = "git-stub checkout master" ]
|
||||
[ "${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" ]
|
||||
@@ -111,7 +111,7 @@ main() {
|
||||
|
||||
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 "checkout master --"
|
||||
shellmock_expect git --type exact --match "add ."
|
||||
shellmock_expect git --type partial --match '-c'
|
||||
shellmock_expect git --type partial --match 'push origin'
|
||||
@@ -123,7 +123,7 @@ main() {
|
||||
shellmock_verify
|
||||
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||
[ "${capture[1]}" = "git-stub fetch" ]
|
||||
[ "${capture[2]}" = "git-stub checkout master" ]
|
||||
[ "${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" ]
|
||||
@@ -148,7 +148,7 @@ main() {
|
||||
|
||||
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 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'
|
||||
@@ -167,7 +167,7 @@ main() {
|
||||
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[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" ]
|
||||
@@ -181,7 +181,7 @@ main() {
|
||||
|
||||
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 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'
|
||||
@@ -198,7 +198,7 @@ main() {
|
||||
shellmock_verify
|
||||
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||
[ "${capture[1]}" = "git-stub fetch" ]
|
||||
[ "${capture[2]}" = "git-stub checkout master" ]
|
||||
[ "${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" ]
|
||||
@@ -214,7 +214,7 @@ main() {
|
||||
|
||||
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 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'
|
||||
@@ -231,7 +231,7 @@ main() {
|
||||
shellmock_verify
|
||||
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||
[ "${capture[1]}" = "git-stub fetch" ]
|
||||
[ "${capture[2]}" = "git-stub checkout master" ]
|
||||
[ "${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" ]
|
||||
@@ -245,7 +245,7 @@ main() {
|
||||
|
||||
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 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'
|
||||
@@ -265,7 +265,7 @@ main() {
|
||||
shellmock_verify
|
||||
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||
[ "${capture[1]}" = "git-stub fetch" ]
|
||||
[ "${capture[2]}" = "git-stub checkout master" ]
|
||||
[ "${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" ]
|
||||
@@ -281,7 +281,7 @@ main() {
|
||||
|
||||
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 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'
|
||||
@@ -301,7 +301,7 @@ main() {
|
||||
shellmock_verify
|
||||
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||
[ "${capture[1]}" = "git-stub fetch" ]
|
||||
[ "${capture[2]}" = "git-stub checkout master" ]
|
||||
[ "${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" ]
|
||||
@@ -316,7 +316,7 @@ main() {
|
||||
|
||||
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 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'
|
||||
@@ -344,7 +344,7 @@ main() {
|
||||
shellmock_verify
|
||||
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||
[ "${capture[1]}" = "git-stub fetch" ]
|
||||
[ "${capture[2]}" = "git-stub checkout foo" ]
|
||||
[ "${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" ]
|
||||
@@ -359,7 +359,7 @@ main() {
|
||||
|
||||
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 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'
|
||||
@@ -387,7 +387,7 @@ main() {
|
||||
shellmock_verify
|
||||
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||
[ "${capture[1]}" = "git-stub fetch" ]
|
||||
[ "${capture[2]}" = "git-stub checkout" ]
|
||||
[ "${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" ]
|
||||
@@ -402,7 +402,7 @@ main() {
|
||||
|
||||
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 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'
|
||||
@@ -430,7 +430,7 @@ main() {
|
||||
shellmock_verify
|
||||
[ "${capture[0]}" = "git-stub status -s -- ." ]
|
||||
[ "${capture[1]}" = "git-stub fetch" ]
|
||||
[ "${capture[2]}" = "git-stub checkout" ]
|
||||
[ "${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" ]
|
@@ -3,6 +3,6 @@
|
||||
|
||||
|
||||
bats@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/bats/-/bats-1.1.0.tgz#6fc44f283ed4e7af2b6ffac93ec5026a1acbdc66"
|
||||
integrity sha512-1pA29OhDByrUtAXX+nmqZxgRgx2y8PvuZzbLJVjd2dpEDVDvz0MjcBMdmIPNq5lC+tG53G+RbeRsbIlv3vw7tg==
|
||||
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