Skip to content

Commit 5b22665

Browse files
authored
fix: implement no-commit config option (#6)
1 parent 3997c0f commit 5b22665

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

action.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ runs:
6767
echo command="$command" >> $GITHUB_OUTPUT
6868
6969
- name: Get PR info
70-
if: ${{ inputs.pr }}
70+
if: inputs.pr
7171
id: pr-info
7272
shell: bash
7373
run: |
@@ -88,7 +88,7 @@ runs:
8888
run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> "$GITHUB_OUTPUT"
8989

9090
- name: Post job start comment
91-
if: ${{ inputs.pr || inputs.comment-id }}
91+
if: inputs.pr || inputs.comment-id
9292
uses: peter-evans/create-or-update-comment@v4
9393
id: comment-start
9494
with:
@@ -102,15 +102,15 @@ runs:
102102
> [1]: ${{ steps.vars.outputs.run-url }}
103103
104104
- name: Checkout PR
105-
if: ${{ inputs.pr }}
105+
if: inputs.pr
106106
uses: actions/checkout@v4
107107
with:
108108
ref: ${{ steps.pr-info.outputs.branch }}
109109
repository: ${{ steps.pr-info.outputs.repo }}
110110
token: ${{ inputs.github-token }}
111111

112112
- name: Checkout default branch (no existing PR)
113-
if: ${{ ! inputs.pr }}
113+
if: "! inputs.pr"
114114
uses: actions/checkout@v4
115115
with:
116116
repository: ${{ steps.pr-info.outputs.repo }}
@@ -142,14 +142,20 @@ runs:
142142
- name: Auto commit changes
143143
id: auto-commit
144144
uses: stefanzweifel/git-auto-commit-action@v5
145-
if: inputs.pr && github.ref != 'refs/heads/master'
145+
if: >
146+
inputs.no-commit != 'true'
147+
&& inputs.pr
148+
&& github.ref != 'refs/heads/master'
149+
&& github.ref != 'refs/heads/main'
146150
with:
147151
commit_message: "Auto-committed changes from Poe command `${{ steps.resolve-command.outputs.command }}`"
148152
commit_user_name: Octavia Squidington III
149153
commit_user_email: [email protected]
150154

151155
- name: Append success comment
152-
if: steps.comment-start.outputs.comment-id && steps.auto-commit.outputs.changes_detected == 'true'
156+
if: >
157+
steps.comment-start.outputs.comment-id
158+
&& steps.auto-commit.outputs.changes_detected == 'true'
153159
uses: peter-evans/create-or-update-comment@v4
154160
with:
155161
comment-id: ${{ steps.comment-start.outputs.comment-id }}
@@ -158,7 +164,9 @@ runs:
158164
✅ Poe command `${{ steps.resolve-command.outputs.command }}` completed successfully.
159165
160166
- name: Append no-op comment
161-
if: steps.comment-start.outputs.comment-id && steps.auto-commit.outputs.changes_detected != 'true'
167+
if: >
168+
steps.comment-start.outputs.comment-id
169+
&& steps.auto-commit.outputs.changes_detected != 'true'
162170
uses: peter-evans/create-or-update-comment@v4
163171
with:
164172
comment-id: ${{ steps.comment-start.outputs.comment-id }}
@@ -178,7 +186,9 @@ runs:
178186
# Create a new PR if no PR was provided
179187

180188
- name: Create Pull Request
181-
if: ${{ ! inputs.pr }}
189+
if: >
190+
inputs.no-commit != 'true'
191+
&& ! inputs.pr
182192
id: create-pr
183193
uses: peter-evans/create-pull-request@v7
184194
with:
@@ -201,7 +211,11 @@ runs:
201211
token: ${{ inputs.github-token }}
202212

203213
- name: Append PR link to comment
204-
if: ${{ steps.comment-start.outputs.comment-id && ! inputs.pr && steps.create-pr.outputs.pull-request-url }}
214+
if: >
215+
steps.comment-start.outputs.comment-id
216+
&& inputs.no-commit != 'true'
217+
&& ! inputs.pr
218+
&& steps.create-pr.outputs.pull-request-url
205219
uses: peter-evans/create-or-update-comment@v4
206220
with:
207221
comment-id: ${{ steps.comment-start.outputs.comment-id }}

0 commit comments

Comments
 (0)