Skip to content

Commit

Permalink
Commit changes by default (#1)
Browse files Browse the repository at this point in the history
* Commit changes by default

* Fix predicate

* Add logs

* Fix predicate and logs

* Move no-commit logs to debug

* Update README.md
  • Loading branch information
nimrodkor authored May 4, 2021
1 parent a966d37 commit 04bf3da
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ jobs:
fetch-depth: 0
- name: Run yor action
uses: bridgecrewio/yor-action@main
- name: Commit tag changes
uses: stefanzweifel/git-auto-commit-action@v4
```
Note that this example uses the latest version (`main`).
Expand All @@ -47,8 +45,6 @@ jobs:
tag_groups: git,code2cloud
custom_tags: path/to/plugin.so
output_format: json
- name: Commit tag changes
uses: stefanzweifel/git-auto-commit-action@v4
```

#### Using skip_tags + tag_groups Parameters
Expand All @@ -74,3 +70,18 @@ jobs:
- name: Commit tag changes
uses: stefanzweifel/git-auto-commit-action@v4
```
#### Committing at your own timing instead of right after the tags were updated:
```yaml
jobs:
yor-job:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Run yor action
uses: bridgecrewio/yor-action@main
with:
commit_changes: NO # Any value which is not YES (which is the default value) will lead to no commit
```
4 changes: 4 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ inputs:
log_level:
description: 'log level'
required: false
commit_changes:
description: 'Choose whether the action will commit changes. Changes will be commited if this is exactly "YES"'
default: YES
required: false

branding:
icon: 'shield'
Expand Down
24 changes: 23 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,26 @@ echo "running yor on directory: $INPUT_DIRECTORY"
/go/yor/yor tag -d "$INPUT_DIRECTORY" "$TAG_FLAG" "$TAG_GROUPS" "$SKIP_TAG_FLAG" "$SKIP_DIR_FLAG" "$EXT_TAGS_FLAG" "$OUTPUT_FLAG"
rm -rf .yor_plugins
YOR_EXIT_CODE=$?
exit $YOR_EXIT_CODE

_git_is_dirty() {
[ -n "$(git status -s --untracked-files=no)" ]
}

if [[ $YOR_EXIT_CODE -eq 0 && $INPUT_COMMIT_CHANGES == "YES" ]]
then
if _git_is_dirty
then
echo "Yor made changes, committing"
git add .
git -c [email protected] -c user.email="GitHub Actions" \
commit -m "Update tags (by Yor)" \
--author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" ;
echo "Changes committed, pushing..."
git push origin
fi
else
echo "::debug::exiting, yor failed or commit is skipped"
echo "::debug::yor exit code: $YOR_EXIT_CODE"
echo "::debug::commit_changes: $INPUT_COMMIT_CHANGES"
exit $YOR_EXIT_CODE
fi

0 comments on commit 04bf3da

Please sign in to comment.