File tree Expand file tree Collapse file tree 3 files changed +42
-5
lines changed
Expand file tree Collapse file tree 3 files changed +42
-5
lines changed Original file line number Diff line number Diff line change 2020 fetch-depth : 0
2121 - name : Run yor action
2222 uses : bridgecrewio/yor-action@main
23- - name : Commit tag changes
24- uses : stefanzweifel/git-auto-commit-action@v4
2523` ` `
2624
2725Note that this example uses the latest version (` main`).
4745 tag_groups: git,code2cloud
4846 custom_tags: path/to/plugin.so
4947 output_format: json
50- - name: Commit tag changes
51- uses: stefanzweifel/git-auto-commit-action@v4
5248` ` `
5349
5450# ### Using skip_tags + tag_groups Parameters
7470 - name: Commit tag changes
7571 uses: stefanzweifel/git-auto-commit-action@v4
7672` ` `
73+ # ### Committing at your own timing instead of right after the tags were updated:
74+ ` ` ` yaml
75+ jobs:
76+ yor-job:
77+ runs-on: ubuntu-latest
78+ steps:
79+ - name: Checkout repo
80+ uses: actions/checkout@v2
81+ with:
82+ fetch-depth: 0
83+ - name: Run yor action
84+ uses: bridgecrewio/yor-action@main
85+ with:
86+ commit_changes: NO # Any value which is not YES (which is the default value) will lead to no commit
87+ ` ` `
Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ inputs:
2626 log_level :
2727 description : ' log level'
2828 required : false
29+ commit_changes :
30+ description : ' Choose whether the action will commit changes. Changes will be commited if this is exactly "YES"'
31+ default : YES
32+ required : false
2933
3034branding :
3135 icon : ' shield'
Original file line number Diff line number Diff line change @@ -16,4 +16,26 @@ echo "running yor on directory: $INPUT_DIRECTORY"
1616/go/yor/yor tag -d " $INPUT_DIRECTORY " " $TAG_FLAG " " $TAG_GROUPS " " $SKIP_TAG_FLAG " " $SKIP_DIR_FLAG " " $EXT_TAGS_FLAG " " $OUTPUT_FLAG "
1717rm -rf .yor_plugins
1818YOR_EXIT_CODE=$?
19- exit $YOR_EXIT_CODE
19+
20+ _git_is_dirty () {
21+ [ -n " $( git status -s --untracked-files=no) " ]
22+ }
23+
24+ if [[ $YOR_EXIT_CODE -eq 0 && $INPUT_COMMIT_CHANGES == " YES" ]]
25+ then
26+ if _git_is_dirty
27+ then
28+ echo " Yor made changes, committing"
29+ git add .
30+ git -c user.name=actions@github.com -c user.email=" GitHub Actions" \
31+ commit -m " Update tags (by Yor)" \
32+ --author=" github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" ;
33+ echo " Changes committed, pushing..."
34+ git push origin
35+ fi
36+ else
37+ echo " ::debug::exiting, yor failed or commit is skipped"
38+ echo " ::debug::yor exit code: $YOR_EXIT_CODE "
39+ echo " ::debug::commit_changes: $INPUT_COMMIT_CHANGES "
40+ exit $YOR_EXIT_CODE
41+ fi
You can’t perform that action at this time.
0 commit comments