diff --git a/.github/workflows/git-auto-commit.yml b/.github/workflows/git-auto-commit.yml new file mode 100644 index 0000000..a9f16ff --- /dev/null +++ b/.github/workflows/git-auto-commit.yml @@ -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\"" 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 diff --git a/README.md b/README.md index bb698cc..e6cbc07 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 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' 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 }