Skip to content

Default to draft PR #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. Accepts `draft` or `open`.

## 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.
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'. Accepts 'draft' or 'open'.
required: false
default: 'draft'
runs:
using: composite
steps:
Expand All @@ -45,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

6 changes: 5 additions & 1 deletion bin/validate-plugin-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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