From 00d73f6b01d98e1116912a7d948eaed5b3cd66d9 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Tue, 18 Feb 2025 09:13:57 -0700 Subject: [PATCH 1/7] add the `--draft` flag --- bin/validate-plugin-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/validate-plugin-version.sh b/bin/validate-plugin-version.sh index 5b75434..6c2609c 100644 --- a/bin/validate-plugin-version.sh +++ b/bin/validate-plugin-version.sh @@ -138,7 +138,7 @@ main() { BASE_BRANCH="${BRANCH:-$DEFAULT_BRANCH}" echo "Creating a pull request with base branch $BASE_BRANCH." - 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" + 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" --draft } main \ No newline at end of file From 23ee6c699936aaf28c53833dbcf7f967e6a3be6c Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Tue, 18 Feb 2025 09:14:10 -0700 Subject: [PATCH 2/7] add a param to specify the pr status --- README.md | 3 +++ action.yml | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 26d4b87..b607959 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,9 @@ A comma-separated list of filenames to check for the "Tested Up To" version. If #### `branch` 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). +#### `pr-status` +The status to set on the PR. If not specified, the action will create a _draft_ PR. + ## Permissions 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. diff --git a/action.yml b/action.yml index b1bfc08..2670ded 100644 --- a/action.yml +++ b/action.yml @@ -25,6 +25,10 @@ inputs: description: The branch to use as the base for PRs and commit the changes back to. required: false default: 'main' + pr-status: + description: The status of the PR to create. Default is 'draft'. + required: false + default: 'draft' runs: using: composite steps: From 7ab64d7f320967807e411b4e5684252846b2a012 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Tue, 18 Feb 2025 09:17:40 -0700 Subject: [PATCH 3/7] define the other option (besides draft) --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 2670ded..82d2513 100644 --- a/action.yml +++ b/action.yml @@ -26,7 +26,7 @@ inputs: required: false default: 'main' pr-status: - description: The status of the PR to create. Default is 'draft'. + description: The status of the PR to create. Default is 'draft'. Accepts 'draft' or 'open'. required: false default: 'draft' runs: @@ -49,5 +49,6 @@ runs: GH_TOKEN: ${{ inputs.gh-token }} FILENAMES: ${{ inputs.filenames }} BRANCH: ${{ inputs.branch }} + PR_STATUS: ${{ inputs.pr-status }} run: bash ${{ github.action_path }}/bin/validate-plugin-version.sh \ No newline at end of file From 8eeefe11abce10160022e647e37a25edbfa3843c Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Tue, 18 Feb 2025 09:18:01 -0700 Subject: [PATCH 4/7] add --draft if 'open' was not passed --- bin/validate-plugin-version.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/validate-plugin-version.sh b/bin/validate-plugin-version.sh index 6c2609c..144b23a 100644 --- a/bin/validate-plugin-version.sh +++ b/bin/validate-plugin-version.sh @@ -138,7 +138,11 @@ main() { BASE_BRANCH="${BRANCH:-$DEFAULT_BRANCH}" echo "Creating a pull request with base branch $BASE_BRANCH." - 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" --draft + 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\"" + if [[ "${PR_STATUS:-}" != "open" ]]; then + PR_OPTIONS="$PR_OPTIONS --draft" + fi + gh pr create $PR_OPTIONS } main \ No newline at end of file From b36231fe99aa6ab240ea66be463c6536fb47c1c8 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Tue, 18 Feb 2025 09:18:32 -0700 Subject: [PATCH 5/7] update readme to include available statuses --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b607959..f91561f 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ A comma-separated list of filenames to check for the "Tested Up To" version. If 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). #### `pr-status` -The status to set on the PR. If not specified, the action will create a _draft_ PR. +The status to set on the PR. If not specified, the action will create a _draft_ PR. Accepts `draft` or `open`. ## Permissions From abd7c8e36f3adc83844aeed12cc7adc0178156a1 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Tue, 18 Feb 2025 09:25:15 -0700 Subject: [PATCH 6/7] wrap variable in brackets --- bin/validate-plugin-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/validate-plugin-version.sh b/bin/validate-plugin-version.sh index 144b23a..9c1e2ff 100644 --- a/bin/validate-plugin-version.sh +++ b/bin/validate-plugin-version.sh @@ -140,7 +140,7 @@ main() { echo "Creating a pull request with base branch $BASE_BRANCH." 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\"" if [[ "${PR_STATUS:-}" != "open" ]]; then - PR_OPTIONS="$PR_OPTIONS --draft" + PR_OPTIONS="${PR_OPTIONS} --draft" fi gh pr create $PR_OPTIONS } From 4c576e6954be4193616d8761efc055d8c7317db5 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Tue, 18 Feb 2025 09:26:49 -0700 Subject: [PATCH 7/7] wrap PR_OPTIONS in quotes --- bin/validate-plugin-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/validate-plugin-version.sh b/bin/validate-plugin-version.sh index 9c1e2ff..62bf413 100644 --- a/bin/validate-plugin-version.sh +++ b/bin/validate-plugin-version.sh @@ -142,7 +142,7 @@ main() { if [[ "${PR_STATUS:-}" != "open" ]]; then PR_OPTIONS="${PR_OPTIONS} --draft" fi - gh pr create $PR_OPTIONS + gh pr create "$PR_OPTIONS" } main \ No newline at end of file