feat: can receive number as input

This commit is contained in:
marocchino 2019-12-18 13:53:53 +09:00
parent 09865a51d0
commit 6ecc72b81e
No known key found for this signature in database
GPG key ID: AFF521DBDB122570
4 changed files with 31 additions and 6 deletions

19
.github/workflows/comment_on_push.yml vendored Normal file
View 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.

View file

@ -4,8 +4,13 @@ author: "marocchino"
inputs:
message:
description: "comment message"
required: true
number:
description: "pull request number for push event"
required: false
GITHUB_TOKEN:
description: "set secrets.GITHUB_TOKEN here"
required: true
runs:
using: "node12"
main: "lib/main.js"

View file

@ -24,11 +24,11 @@ function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
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 githubToken = core.getInput("GITHUB_TOKEN");
if (!number) {
core.setFailed("This action only works for pull_request");
if (isNaN(number)) {
core.setFailed("not found pull request number");
return;
}
if (!body || !githubToken) {

View file

@ -4,11 +4,12 @@ import { findPreviousComment, createComment, updateComment } from "./comment";
async function run() {
try {
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 githubToken = core.getInput("GITHUB_TOKEN");
if (!number) {
core.setFailed("This action only works for pull_request");
if (isNaN(number)) {
core.setFailed("not found pull request number");
return;
}
if (!body || !githubToken) {