Skip to content

Commit 5ddcc7f

Browse files
authored
Default to draft PR (#15)
* add the `--draft` flag * add a param to specify the pr status * define the other option (besides draft) * add --draft if 'open' was not passed * update readme to include available statuses * wrap variable in brackets * wrap PR_OPTIONS in quotes
1 parent 90a84fb commit 5ddcc7f

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ A comma-separated list of filenames to check for the "Tested Up To" version. If
5151
#### `branch`
5252
The branch to create the PR against. If not specified, the action will use the branch the workflow is running on (default branch for cron-triggered workflows).
5353

54+
#### `pr-status`
55+
The status to set on the PR. If not specified, the action will create a _draft_ PR. Accepts `draft` or `open`.
56+
5457
## Permissions
5558

5659
The `write` permissions on `contents` and `pull-requests` are important. They are required for the action to commit the changes back to the repository and open a pull request. The only files affected by the action are files named `readme.txt`, `README.md` or those files matching the pattern (looking for "Tested Up To" in the file) that have been specified in the `filenames` input.

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ inputs:
2525
description: The branch to use as the base for PRs and commit the changes back to.
2626
required: false
2727
default: 'main'
28+
pr-status:
29+
description: The status of the PR to create. Default is 'draft'. Accepts 'draft' or 'open'.
30+
required: false
31+
default: 'draft'
2832
runs:
2933
using: composite
3034
steps:
@@ -45,5 +49,6 @@ runs:
4549
GH_TOKEN: ${{ inputs.gh-token }}
4650
FILENAMES: ${{ inputs.filenames }}
4751
BRANCH: ${{ inputs.branch }}
52+
PR_STATUS: ${{ inputs.pr-status }}
4853
run: bash ${{ github.action_path }}/bin/validate-plugin-version.sh
4954

bin/validate-plugin-version.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ main() {
138138
BASE_BRANCH="${BRANCH:-$DEFAULT_BRANCH}"
139139

140140
echo "Creating a pull request with base branch $BASE_BRANCH."
141-
gh pr create --title "Update Tested Up To version to $CURRENT_WP_VERSION" --body "This pull request updates the \"Tested up to\" version in specified files (${FILENAMES}) to match the current WordPress version $CURRENT_WP_VERSION." --base "$BASE_BRANCH"
141+
local PR_OPTIONS="--title \"Update Tested Up To version to $CURRENT_WP_VERSION\" --body \"This pull request updates the 'Tested up to' version in specified files (${FILENAMES}) to match the current WordPress version $CURRENT_WP_VERSION.\" --base \"$BASE_BRANCH\""
142+
if [[ "${PR_STATUS:-}" != "open" ]]; then
143+
PR_OPTIONS="${PR_OPTIONS} --draft"
144+
fi
145+
gh pr create "$PR_OPTIONS"
142146
}
143147

144148
main

0 commit comments

Comments
 (0)