Skip to content

Commit

Permalink
Allow passing a file-path as PR body
Browse files Browse the repository at this point in the history
Sometimes the PR body contains a lot of information. In this case
passing it as argument to the action will cause a shell error of having
an argument list that's too long. To circumvent this we provide the
option of providing a file path that is loaded by Node instead.

We prefer the file-path but fall back to the body.
  • Loading branch information
Kingdutch committed Aug 30, 2022
1 parent 6e59b07 commit 611bc47
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ inputs:
body:
description: 'The body of the pull request.'
default: 'Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action'
body-file:
description: 'Use the contents of this file as body rather than the body parameter.'
labels:
description: 'A comma or newline separated list of labels.'
assignees:
Expand Down
8 changes: 7 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(2186));
const create_pull_request_1 = __nccwpck_require__(3780);
const fs_1 = __nccwpck_require__(7147);
const util_1 = __nccwpck_require__(3837);
const utils = __importStar(__nccwpck_require__(918));
function run() {
Expand All @@ -1111,7 +1112,12 @@ function run() {
base: core.getInput('base'),
pushToFork: core.getInput('push-to-fork'),
title: core.getInput('title'),
body: core.getInput('body'),
body: core.getInput('body-file') !== ''
? (0, fs_1.readFileSync)(core.getInput('body-file'), {
encoding: 'utf8',
flag: 'r'
})
: core.getInput('body'),
labels: utils.getInputAsArray('labels'),
assignees: utils.getInputAsArray('assignees'),
reviewers: utils.getInputAsArray('reviewers'),
Expand Down
9 changes: 8 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as core from '@actions/core'
import {Inputs, createPullRequest} from './create-pull-request'
import {readFileSync} from 'fs'
import {inspect} from 'util'
import * as utils from './utils'

Expand All @@ -19,7 +20,13 @@ async function run(): Promise<void> {
base: core.getInput('base'),
pushToFork: core.getInput('push-to-fork'),
title: core.getInput('title'),
body: core.getInput('body'),
body:
core.getInput('body-file') !== ''
? readFileSync(core.getInput('body-file'), {
encoding: 'utf8',
flag: 'r'
})
: core.getInput('body'),
labels: utils.getInputAsArray('labels'),
assignees: utils.getInputAsArray('assignees'),
reviewers: utils.getInputAsArray('reviewers'),
Expand Down

0 comments on commit 611bc47

Please sign in to comment.