Skip to content

Commit de39ef1

Browse files
authored
IT-3795 let the draft state of the fmt PR be controllable (#82)
* let the draft state of the fmt PR be controllable * avoid code injection by using env var
1 parent 55da8ce commit de39ef1

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/format.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ on:
1313
type: string
1414
required: true
1515

16+
create_pr_draft:
17+
description: Whether the format-fixing PR should be opened as a draft
18+
type: boolean
19+
required: false
20+
default: true
21+
1622
jobs:
1723
format:
1824
name: Format
@@ -51,17 +57,18 @@ jobs:
5157
uses: Brightspace/third-party-actions@actions/github-script
5258
env:
5359
BRANCH_NAME: ${{ steps.format.outputs.format_branch }}
60+
CREATE_PR_DRAFT: ${{ inputs.create_pr_draft }}
5461
with:
5562
script: |
56-
const { BRANCH_NAME } = process.env
63+
const { BRANCH_NAME, CREATE_PR_DRAFT } = process.env
5764
const { data: newPr } = await github.rest.pulls.create({
5865
owner: context.repo.owner,
5966
repo: context.repo.repo,
6067
title: `Auto format #${context.payload.number}`,
6168
body: `Auto format #${context.payload.number}`,
6269
head: BRANCH_NAME,
6370
base: context.payload.pull_request.head.ref,
64-
draft: true
71+
draft: CREATE_PR_DRAFT === 'true'
6572
});
6673
await github.rest.issues.createComment({
6774
issue_number: context.issue.number,

0 commit comments

Comments
 (0)