File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : " Post comment"
2+ description : " Create or update a sticky PR comment identified by a caller-provided marker."
3+ inputs :
4+ marker :
5+ description : >
6+ Non-empty plain-text identifier for the comment. Use a unique, stable value
7+ for each distinct comment; it is automatically wrapped in a hidden HTML comment.
8+ required : true
9+ body :
10+ description : " Full comment markdown."
11+ required : true
12+ update-only :
13+ description : Do nothing if no comment with the specified marker exists.
14+ required : false
15+ default : " false"
16+ issue-id :
17+ description : >
18+ The issue or pull request number to post/update the comment on.
19+ Defaults to the current pull request if not provided.
20+ required : false
21+ token :
22+ description : " The GitHub token to authenticate with."
23+ required : true
24+ runs :
25+ using : composite
26+ steps :
27+ - name : Post comment
28+ shell : bash
29+ env :
30+ BODY : ${{ inputs.body }}
31+ MARKER : ${{ inputs.marker }}
32+ UPDATE_ONLY : ${{ case(inputs.update-only == 'true', '--update-only', '') }}
33+ GH_TOKEN : ${{ inputs.token }}
34+ ISSUE_ID : ${{ inputs.issue-id || github.event.pull_request.number }}
35+ run : |
36+ npx tsx ./pr-checks/post-comment.ts \
37+ --body "$BODY" \
38+ --marker "$MARKER" \
39+ $UPDATE_ONLY \
40+ --issue-id "$ISSUE_ID" \
41+ --repository "$GITHUB_REPOSITORY"
Original file line number Diff line number Diff line change @@ -8,3 +8,14 @@ export function getApiClient(token: string): ApiClient {
88 const opts = githubUtils . getOctokitOptions ( token ) ;
99 return new githubUtils . GitHub ( opts ) ;
1010}
11+
12+ /** Resolves the GitHub API token to use, from `GH_TOKEN` or `GITHUB_TOKEN`. */
13+ export function resolveToken ( env : NodeJS . ProcessEnv ) : string {
14+ const token = env . GH_TOKEN ?. trim ( ) || env . GITHUB_TOKEN ?. trim ( ) ;
15+ if ( ! token ) {
16+ throw new Error (
17+ "Missing authentication token. Set GH_TOKEN or GITHUB_TOKEN." ,
18+ ) ;
19+ }
20+ return token ;
21+ }
You can’t perform that action at this time.
0 commit comments