Skip to content

Commit 7bdd196

Browse files
committed
Add the handle-pr-comment GitHub Action
This is the culmination of all the preparation: The first GitHub Action that will be used in a GitHub workflow that will replace these trusty Azure Pipelines we used for so long: - GitGitGadget PR Handler: https://dev.azure.com/gitgitgadget/git/_build?definitionId=3 - GitGitGadget PR Handler (git): https://dev.azure.com/gitgitgadget/git/_build?definitionId=13 - GitGitGadget PR Handler (dscho): https://dev.azure.com/gitgitgadget/git/_build?definitionId=12 Note that this Action receives the full `pr-comment-url` as Action input; Readers might wonder why the Action cannot receive the information in a more fine-grained manner, seeing as the `github` context of a GitHub workflow triggered by a new PR comment already has all the necessary values. But this would require adding a GitGitGadget-specific workflow to the main `git/git` repository, something that was considered in gitgitgadget/gitgitgadget#861 but which would be _extremely_ difficult to convince the core Git contributors to accept. Therefore, the GitHub workflow using this Action will be a `workflow_dispatch`-triggered one, for more details see gitgitgadget-workflows/gitgitgadget-workflows#1. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent b8437bb commit 7bdd196

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

handle-pr-comment/action.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: 'Handle PR Comment'
2+
description: 'Handles slash commands such as /submit and /preview'
3+
author: 'Johannes Schindelin'
4+
inputs:
5+
pr-repo-token:
6+
description: 'The access token to work on the repository that holds PRs and state'
7+
required: true
8+
upstream-repo-token:
9+
description: 'The access token to work on PRs in the upstream repository'
10+
required: true
11+
test-repo-token:
12+
description: 'The access token to work on PRs in the test repository'
13+
required: true
14+
smtp-host:
15+
description: 'The SMTP host to use for sending emails'
16+
required: true
17+
smtp-user:
18+
description: 'The SMTP user when sending emails'
19+
required: true
20+
smtp-opts:
21+
description: 'Extra SMTP options in JSON format'
22+
required: false
23+
smtp-pass:
24+
description: 'The SMTP password to use for sending emails'
25+
required: true
26+
pr-comment-url:
27+
description: 'The URL of the PR comment to add a reaction to'
28+
required: true
29+
runs:
30+
using: 'node20'
31+
main: './index.js'
32+
branding:
33+
icon: 'git-commit'
34+
color: 'orange'

handle-pr-comment/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
async function run() {
2+
const { CIHelper } = await import("../dist/index.js")
3+
4+
const ci = new CIHelper()
5+
const { owner, commentId } = ci.parsePRCommentURLInput()
6+
7+
await ci.setupGitHubAction()
8+
await ci.handleComment(owner, commentId)
9+
}
10+
11+
run()

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"build": "tsc",
1515
"build-dist": "ncc build -s -m ./lib/ci-helper.ts -o dist",
1616
"cleanbranch": "node ./build/script/delete-test-branches.js",
17-
"lint": "eslint \"{lib,script,tests,tests-config}/**/*.{ts,tsx,mjs,js}\" --ignore-pattern \"dist/**/*\"",
17+
"lint": "eslint \"{lib,script,tests,tests-config}/**/*.{ts,tsx,mjs,js}\" \"*/index.js\" --ignore-pattern \"dist/**/*\"",
1818
"start": "node server.js",
1919
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --env=node",
2020
"test:clean": "jest --clearCache && npm test",

0 commit comments

Comments
 (0)