mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-14 12:31:14 +00:00
feat: can receive number as input
This commit is contained in:
parent
09865a51d0
commit
6ecc72b81e
4 changed files with 31 additions and 6 deletions
19
.github/workflows/comment_on_push.yml
vendored
Normal file
19
.github/workflows/comment_on_push.yml
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
name: Comment on Push
|
||||||
|
on:
|
||||||
|
- push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
comment:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- uses: jwalton/gh-find-current-pr@v1
|
||||||
|
id: finder
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- uses: ./
|
||||||
|
with:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
number: ${{ steps.finder.outputs.pr }}
|
||||||
|
message: |
|
||||||
|
Test ${{ github.sha }} is successfully ended.
|
||||||
|
|
@ -4,8 +4,13 @@ author: "marocchino"
|
||||||
inputs:
|
inputs:
|
||||||
message:
|
message:
|
||||||
description: "comment message"
|
description: "comment message"
|
||||||
|
required: true
|
||||||
|
number:
|
||||||
|
description: "pull request number for push event"
|
||||||
|
required: false
|
||||||
GITHUB_TOKEN:
|
GITHUB_TOKEN:
|
||||||
description: "set secrets.GITHUB_TOKEN here"
|
description: "set secrets.GITHUB_TOKEN here"
|
||||||
|
required: true
|
||||||
runs:
|
runs:
|
||||||
using: "node12"
|
using: "node12"
|
||||||
main: "lib/main.js"
|
main: "lib/main.js"
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,11 @@ function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const repo = github_1.context.repo;
|
const repo = github_1.context.repo;
|
||||||
const number = (_c = (_b = (_a = github_1.context) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.pull_request) === null || _c === void 0 ? void 0 : _c.number;
|
const number = ((_c = (_b = (_a = github_1.context) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.pull_request) === null || _c === void 0 ? void 0 : _c.number) || +core.getInput("number");
|
||||||
const body = core.getInput("message");
|
const body = core.getInput("message");
|
||||||
const githubToken = core.getInput("GITHUB_TOKEN");
|
const githubToken = core.getInput("GITHUB_TOKEN");
|
||||||
if (!number) {
|
if (isNaN(number)) {
|
||||||
core.setFailed("This action only works for pull_request");
|
core.setFailed("not found pull request number");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!body || !githubToken) {
|
if (!body || !githubToken) {
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,12 @@ import { findPreviousComment, createComment, updateComment } from "./comment";
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const repo = context.repo;
|
const repo = context.repo;
|
||||||
const number = context?.payload?.pull_request?.number;
|
const number =
|
||||||
|
context?.payload?.pull_request?.number || +core.getInput("number");
|
||||||
const body = core.getInput("message");
|
const body = core.getInput("message");
|
||||||
const githubToken = core.getInput("GITHUB_TOKEN");
|
const githubToken = core.getInput("GITHUB_TOKEN");
|
||||||
if (!number) {
|
if (isNaN(number)) {
|
||||||
core.setFailed("This action only works for pull_request");
|
core.setFailed("not found pull request number");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!body || !githubToken) {
|
if (!body || !githubToken) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue