generated from actions/container-toolkit-action
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de28dfc
commit 6f6cbdb
Showing
2 changed files
with
32 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,35 @@ | ||
import {GitHub} from '@actions/github/lib/github'; | ||
|
||
const core = require('@actions/core'); | ||
const github = require('@actions/github'); | ||
|
||
async function run() { | ||
const githubContext = github.context; | ||
const githubToken = core.getInput('github-token'); | ||
const githubClient: GitHub = new GitHub(githubToken); | ||
|
||
const titleRegex = new RegExp(core.getInput('title-regex')); | ||
const title = githubContext.payload.pull_request.title; | ||
|
||
const onFailedRegexComment = core.getInput('on-failed-regex-comment') | ||
.replace('%pattern%', titleRegex.source); | ||
|
||
try { | ||
const myInput = core.getInput('myInput'); | ||
core.debug(`Hello ${myInput} from inside a container`); | ||
if (!titleRegex.test(title)) { | ||
const pr = githubContext.issue; | ||
|
||
// Get github context data | ||
const context = github.context; | ||
console.log(`We can even get context data, like the repo: ${context.repo.repo}`) | ||
githubClient.pulls.createReview({ | ||
owner: pr.owner, | ||
repo: pr.repo, | ||
pull_number: pr.number, | ||
body: onFailedRegexComment, | ||
event: 'COMMENT' | ||
}); | ||
} | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
// noinspection JSIgnoredPromiseFromCall | ||
run(); |