From 40956d2dbd191690687ba10fdece64f9c5f2dad5 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Fri, 25 Oct 2019 20:51:12 +0200 Subject: [PATCH 1/7] Add file_pattern argument --- actions.yml | 3 +++ entrypoint.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/actions.yml b/actions.yml index 853234a..5aa28f8 100644 --- a/actions.yml +++ b/actions.yml @@ -10,6 +10,9 @@ inputs: branch: description: Branch where changes should be pushed too required: true + file_pattern: + description: File pattern used for "git add" + default: '.' runs: using: 'docker' diff --git a/entrypoint.sh b/entrypoint.sh index b5d6348..ff9669f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,7 +30,7 @@ then # Switch to branch from current Workflow run git checkout $INPUT_BRANCH - git add . + git add $INPUT_FILE_PATTERN git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" From 03de600c9772c5b8ac85da4bae9ed538a1bd8ab0 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Fri, 25 Oct 2019 20:57:03 +0200 Subject: [PATCH 2/7] Fixes --- entrypoint.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index ff9669f..ea8ca1f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,7 +30,12 @@ then # Switch to branch from current Workflow run git checkout $INPUT_BRANCH - git add $INPUT_FILE_PATTERN + if [ -z ${INPUT_FILE_PATTERN+x} ]; + then + git add . + else + git add $INPUT_FILE_PATTERN + fi git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" From 16f4dc5956fba80457953b991c4e9dfd0a4773f3 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Fri, 25 Oct 2019 22:18:32 +0200 Subject: [PATCH 3/7] Update README --- README.md | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 055872e..8250c2b 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,9 @@ Add the following step at the end of your job. with: commit_message: Apply automatic changes branch: ${{ github.head_ref }} + + # Optional glob pattern of files which should be added to the commit + file_pattern: src/\*.js env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` @@ -27,18 +30,6 @@ The Action will only commit files back, if changes are available. The resulting It is recommended to use this Action in Workflows which listen to the `pull_request` event. If you want to use the Action on other events, you have to hardcode the value for `branch` as `github.head_ref` is only available in Pull Requests. - -### Inputs - -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. @@ -72,11 +63,16 @@ jobs: with: commit_message: Apply php-cs-fixer changes branch: ${{ github.head_ref }} + file_pattern: src/\*.php env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` +### Inputs + +Checkout [`actions.yml`](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/actions.yml) for a full list of supported inputs. + ## 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). From 5de23163f29fe8b49f5ab9bef89026e2ebd8e817 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 26 Oct 2019 12:13:56 +0200 Subject: [PATCH 4/7] Update actions.yml Co-Authored-By: Zsolt Gomori <30864202+gomorizsolt@users.noreply.github.com> --- actions.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/actions.yml b/actions.yml index 5aa28f8..5c28b2a 100644 --- a/actions.yml +++ b/actions.yml @@ -12,6 +12,7 @@ inputs: required: true file_pattern: description: File pattern used for "git add" + required: false default: '.' runs: From d6493da30b540c0f06ff96c4d03ec60052fc5c59 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 26 Oct 2019 13:58:34 +0200 Subject: [PATCH 5/7] Disable if-condition --- entrypoint.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index ea8ca1f..24555a7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,12 +30,14 @@ then # Switch to branch from current Workflow run git checkout $INPUT_BRANCH - if [ -z ${INPUT_FILE_PATTERN+x} ]; - then - git add . - else - git add $INPUT_FILE_PATTERN - fi + # if [ -z ${INPUT_FILE_PATTERN+x} ]; + # then + # git add . + # else + # git add $INPUT_FILE_PATTERN + # fi + + git add $INPUT_FILE_PATTERN git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" From 25c0d721b70d8b72e49d482915ddbd3ebfff751d Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 26 Oct 2019 14:00:59 +0200 Subject: [PATCH 6/7] Reenable if condition --- entrypoint.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 24555a7..609e9b7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,14 +30,13 @@ then # Switch to branch from current Workflow run git checkout $INPUT_BRANCH - # if [ -z ${INPUT_FILE_PATTERN+x} ]; - # then - # git add . - # else - # git add $INPUT_FILE_PATTERN - # fi - - git add $INPUT_FILE_PATTERN + if [ -z ${INPUT_FILE_PATTERN+x} ]; + then + git add . + else + echo "INPUT_FILE_PATTERN value: $INPUT_FILE_PATTERN"; + git add $INPUT_FILE_PATTERN + fi git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" From 92d05a9fc57fc31968b1d431b70a089e404807d2 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 26 Oct 2019 16:33:17 +0200 Subject: [PATCH 7/7] Update CHANGELOG --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0c360f..2dacf4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,12 @@ 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/v2.1.0...HEAD) +## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.2.0...HEAD) + +## [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