From 404d2015f4d4854306fd8fec62c913fddb042f6c Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Tue, 3 Mar 2020 20:51:02 +0100 Subject: [PATCH 1/8] Add Workflow to run git-auto-commit --- .github/workflows/git-auto-commit.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/git-auto-commit.yml diff --git a/.github/workflows/git-auto-commit.yml b/.github/workflows/git-auto-commit.yml new file mode 100644 index 0000000..132d598 --- /dev/null +++ b/.github/workflows/git-auto-commit.yml @@ -0,0 +1,11 @@ +name: git-auto-commit + +on: push + +jobs: + shellcheck: + runs-on: ubuntu-latest + + steps: + - name: Use git-auto-commit-action + uses: ./ From 33e8fd937fd3826e39a0052c691052f8a02ab924 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Tue, 3 Mar 2020 20:51:12 +0100 Subject: [PATCH 2/8] Add changes_detected output --- entrypoint.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 766759b..45c4d13 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,6 +7,8 @@ _main() { if _git_is_dirty; then + echo \"::set-output name=changes_detected::true\" + _setup_git _switch_to_branch @@ -17,6 +19,9 @@ _main() { _push_to_github else + + echo \"::set-output name=changes_detected::false\" + echo "Working tree clean. Nothing to commit." fi } From ae885f5d8ce15b6ea15640d380c6f56c3373350c Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Tue, 3 Mar 2020 20:54:12 +0100 Subject: [PATCH 3/8] WIP --- .github/workflows/git-auto-commit.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/git-auto-commit.yml b/.github/workflows/git-auto-commit.yml index 132d598..269320d 100644 --- a/.github/workflows/git-auto-commit.yml +++ b/.github/workflows/git-auto-commit.yml @@ -3,9 +3,11 @@ name: git-auto-commit on: push jobs: - shellcheck: + git-auto-commit: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 + - name: Use git-auto-commit-action uses: ./ From 25e6f0b17d34386fce2a2231133e5fded773bb1c Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Tue, 3 Mar 2020 21:00:40 +0100 Subject: [PATCH 4/8] Echo changes_detected in workflow --- .github/workflows/git-auto-commit.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/git-auto-commit.yml b/.github/workflows/git-auto-commit.yml index 269320d..d21103c 100644 --- a/.github/workflows/git-auto-commit.yml +++ b/.github/workflows/git-auto-commit.yml @@ -10,4 +10,8 @@ jobs: - uses: actions/checkout@v2 - name: Use git-auto-commit-action + id: "auto-commit-action" uses: ./ + + - name: "outputs" + run: "echo \"${{ steps.auto-commit-action.outputs.changes_detected }}\"" From eef5f33ea3dc5b080446cb0be02d20714d65d308 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Tue, 3 Mar 2020 21:04:57 +0100 Subject: [PATCH 5/8] WIP --- .github/workflows/git-auto-commit.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/git-auto-commit.yml b/.github/workflows/git-auto-commit.yml index d21103c..a9f16ff 100644 --- a/.github/workflows/git-auto-commit.yml +++ b/.github/workflows/git-auto-commit.yml @@ -13,5 +13,10 @@ jobs: id: "auto-commit-action" uses: ./ - - name: "outputs" - run: "echo \"${{ steps.auto-commit-action.outputs.changes_detected }}\"" + - 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\"" From 57bbd38e56db0d997d1e689d899f8b0d9eef4004 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 4 Mar 2020 19:56:33 +0100 Subject: [PATCH 6/8] Add outputs to action.yml --- action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/action.yml b/action.yml index f6b6077..477de4f 100644 --- a/action.yml +++ b/action.yml @@ -35,6 +35,10 @@ inputs: required: false default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> +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' From 8744cc88ef749d1baf28512877b42b1a674c6236 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 4 Mar 2020 20:33:10 +0100 Subject: [PATCH 7/8] Update README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 98bd841..18550b3 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,11 @@ jobs: 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. + ## Troubleshooting ### Can't push commit to repository From f866b2a8547635a98d7953c5569cf666ea47b041 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 4 Mar 2020 20:33:53 +0100 Subject: [PATCH 8/8] Update Changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fba39a8..90dbec0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.0.0...HEAD) -> TBD +### Added +- Add `changes_detected` output [#49](https://github.com/stefanzweifel/git-auto-commit-action/pull/49) ## [v4.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v3.0.0...v4.0.0) - 2020-02-24