Skip to content

Commit 6e22056

Browse files
authored
Merge branch 'main' into dependabot/github_actions/github-actions-a1cff6d793
2 parents 160bd60 + 36e621c commit 6e22056

10 files changed

+96
-33
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979
id: command
8080
with:
8181
command: ".ping"
82+
allowed_contexts: issue,pull_request # run on issues AND pull requests
8283
8384
# run your custom logic for your project here - example seen below
8485
@@ -139,7 +140,7 @@ jobs:
139140
runs-on: ubuntu-latest
140141
steps:
141142
# Checkout your projects repository
142-
- uses: actions/checkout@v3
143+
- uses: actions/checkout@v4
143144
```
144145

145146
Sets up your `demo` job, uses an ubuntu runner, and checks out your repo - Just some standard setup for a general Action. We also add an `if:` statement here to only run this workflow on pull request comments to make it a little more specific (if necessary)
@@ -185,6 +186,8 @@ As seen above, we have a single example step. Perhaps you would actually use a r
185186
| `github_token` | `true` | `${{ github.token }}` | The GitHub token used to create an authenticated client - Provided for you by default! |
186187
| `status` | `true` | `${{ job.status }}` | The status of the GitHub Actions - For use in the post run workflow - Provided for you by default! |
187188
| `reaction` | `true` | `eyes` | If set, the specified emoji "reaction" is put on the comment to indicate that the trigger was detected. For example, "rocket" or "eyes" |
189+
| `success_reaction` | `true` | `+1` | The reaction to add to the comment that triggered the Action if its execution was successful |
190+
| `failure_reaction` | `true` | `-1` | The reaction to add to the comment that triggered the Action if its execution failed |
188191
| `allowed_contexts` | `true` | `pull_request` | A comma separated list of comment contexts that are allowed to trigger this IssueOps command. Pull requests and issues are the only currently supported contexts. To allow IssueOps commands to be invoked from both PRs and issues, set this option to the following: `"pull_request,issue"`. By default, the only place this Action will allow IssueOps commands from is pull requests |
189192
| `permissions` | `true` | `"write,maintain,admin"` | The allowed GitHub permissions an actor can have to invoke IssueOps commands |
190193
| `allow_drafts` | `true` | `"false"` | Whether or not to allow this IssueOps command to be run on draft pull requests |
@@ -213,6 +216,8 @@ As seen above, we have a single example step. Perhaps you would actually use a r
213216
| `fork_label` | The API label field returned for the fork |
214217
| `fork_checkout` | The console command presented in the GitHub UI to checkout a given fork locally |
215218
| `fork_full_name` | The full name of the fork in "org/repo" format |
219+
| `sha` | The commit sha if being used in the context of a pull request |
220+
| `ref` | The ref if being used in the context of a pull request |
216221

217222
## Allowlist 👩‍🔬
218223

__tests__/schemas/action.schema.yml

+28
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,26 @@ inputs:
7777
default:
7878
type: string
7979
required: true
80+
success_reaction:
81+
description:
82+
type: string
83+
required: true
84+
required:
85+
type: boolean
86+
required: true
87+
default:
88+
type: string
89+
required: true
90+
failure_reaction:
91+
description:
92+
type: string
93+
required: true
94+
required:
95+
type: boolean
96+
required: true
97+
default:
98+
type: string
99+
required: true
80100
allowed_contexts:
81101
description:
82102
type: string
@@ -218,6 +238,14 @@ outputs:
218238
description:
219239
type: string
220240
required: true
241+
ref:
242+
description:
243+
type: string
244+
required: true
245+
sha:
246+
description:
247+
type: string
248+
required: true
221249
initial_reaction_id:
222250
description:
223251
type: string

action.yml

+12
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ inputs:
2020
description: 'If set, the specified emoji "reaction" is put on the comment to indicate that the trigger was detected. For example, "rocket" or "eyes"'
2121
required: true
2222
default: "eyes"
23+
success_reaction:
24+
description: 'The reaction to add to the comment that triggered the Action if its execution was successful'
25+
required: true
26+
default: "+1"
27+
failure_reaction:
28+
description: 'The reaction to add to the comment that triggered the Action if its execution failed'
29+
required: true
30+
default: "-1"
2331
allowed_contexts:
2432
description: 'A comma separated list of comment contexts that are allowed to trigger this IssueOps command. Pull requests and issues are the only currently supported contexts'
2533
required: true
@@ -87,6 +95,10 @@ outputs:
8795
description: 'The console command presented in the GitHub UI to checkout a given fork locally'
8896
fork_full_name:
8997
description: 'The full name of the fork in "org/repo" format'
98+
sha:
99+
description: 'The commit sha if being used in the context of a pull request'
100+
ref:
101+
description: 'The ref if being used in the context of a pull request'
90102
runs:
91103
using: "node20"
92104
main: "dist/index.js"

dist/index.js

+22-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"devDependencies": {
5353
"@babel/plugin-transform-modules-commonjs": "^7.25.9",
5454
"@babel/preset-env": "^7.26.0",
55-
"@types/node": "^22.10.0",
55+
"@types/node": "^22.10.1",
5656
"@vercel/ncc": "^0.38.3",
5757
"@babel/core": "^7.26.0",
5858
"babel-jest": "^29.7.0",

src/functions/post-reactions.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
// :param reaction: The reaction to add to the issue_comment
55
// :param reaction_id: The reaction_id of the initial reaction on the issue_comment
66
export async function postReactions(octokit, context, reaction, reaction_id) {
7-
// Update the action status to indicate the result of the action as a reaction
8-
// add a reaction to the issue_comment to indicate success or failure
9-
await octokit.rest.reactions.createForIssueComment({
7+
// remove the initial reaction on the IssueOp comment that triggered this action
8+
await octokit.rest.reactions.deleteForIssueComment({
109
...context.repo,
1110
comment_id: context.payload.comment.id,
12-
content: reaction
11+
reaction_id: parseInt(reaction_id)
1312
})
1413

15-
// remove the initial reaction on the IssueOp comment that triggered this action
16-
await octokit.rest.reactions.deleteForIssueComment({
14+
// Update the action status to indicate the result of the action as a reaction
15+
// add a reaction to the issue_comment to indicate success or failure
16+
await octokit.rest.reactions.createForIssueComment({
1717
...context.repo,
1818
comment_id: context.payload.comment.id,
19-
reaction_id: parseInt(reaction_id)
19+
content: reaction
2020
})
2121
}

src/functions/post.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ export async function post() {
5050
}
5151

5252
// Select the reaction to add to the issue_comment
53+
// If it is a success, use the user defined reaction
54+
// Otherwise, add a thumbs down reaction
5355
var reaction
5456
if (success) {
55-
reaction = thumbsUp
57+
reaction = core.getInput('success_reaction') || thumbsUp
5658
} else {
57-
reaction = thumbsDown
59+
reaction = core.getInput('failed_reaction') || thumbsDown
5860
}
5961

6062
// Update the reactions on the command comment

src/functions/prechecks.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ export async function prechecks(
245245
// CI checks are set to be bypassed and the PR has not been reviewed
246246
} else if (
247247
commitStatus === 'skip_ci' &&
248-
reviewDecision === 'REVIEW_REQUIRED'
248+
(reviewDecision === 'REVIEW_REQUIRED' ||
249+
reviewDecision === 'CHANGES_REQUESTED')
249250
) {
250251
message = `### ⚠️ Cannot proceed with operation\n\n> CI checks are not required for this operation but the PR has not been reviewed`
251252
return {message: message, status: false}
@@ -257,7 +258,8 @@ export async function prechecks(
257258

258259
// If CI is passing but the PR has not been reviewed
259260
} else if (
260-
reviewDecision === 'REVIEW_REQUIRED' &&
261+
(reviewDecision === 'REVIEW_REQUIRED' ||
262+
reviewDecision === 'CHANGES_REQUESTED') &&
261263
commitStatus === 'SUCCESS'
262264
) {
263265
message = `### ⚠️ Cannot proceed with operation\n\n> CI checks are passing but the PR has not been reviewed`
@@ -270,7 +272,8 @@ export async function prechecks(
270272

271273
// If CI is pending and the PR has not been reviewed
272274
} else if (
273-
reviewDecision === 'REVIEW_REQUIRED' &&
275+
(reviewDecision === 'REVIEW_REQUIRED' ||
276+
reviewDecision === 'CHANGES_REQUESTED') &&
274277
commitStatus === 'PENDING'
275278
) {
276279
message = `### ⚠️ Cannot proceed with operation\n\n- reviewDecision: \`${reviewDecision}\`\n- commitStatus: \`${commitStatus}\`\n\n> CI is still in a pending state and reviews are also required for this operation`
@@ -282,7 +285,11 @@ export async function prechecks(
282285
return {message: message, status: false}
283286

284287
// If CI is undefined and the PR has not been reviewed
285-
} else if (reviewDecision === 'REVIEW_REQUIRED' && commitStatus === null) {
288+
} else if (
289+
(reviewDecision === 'REVIEW_REQUIRED' ||
290+
reviewDecision === 'CHANGES_REQUESTED') &&
291+
commitStatus === null
292+
) {
286293
message = `### ⚠️ Cannot proceed with operation\n\n- reviewDecision: \`${reviewDecision}\`\n- commitStatus: \`${commitStatus}\`\n\n> CI checks have not been defined but reviews are required for this operation`
287294
return {message: message, status: false}
288295

0 commit comments

Comments
 (0)