Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Validate Plugin Version Test
on: [pull_request]
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ inputs:
branch:
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
Expand All @@ -50,5 +49,6 @@ runs:
FILENAMES: ${{ inputs.filenames }}
BRANCH: ${{ inputs.branch }}
PR_STATUS: ${{ inputs.pr-status }}
GITHUB_BASE_REF: ${{ github.base_ref }}
run: bash ${{ github.action_path }}/bin/validate-plugin-version.sh

9 changes: 6 additions & 3 deletions bin/validate-plugin-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ set -euo pipefail
IFS=$'\n\t'

main() {
# Determine the default branch
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
if [[ -n "${GITHUB_BASE_REF:-}" ]]; then
DEFAULT_BRANCH="${GITHUB_BASE_REF}"
else
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
fi
echo "Default branch is $DEFAULT_BRANCH"

# Check out the specified branch if $BRANCH is set and not already on it
if [[ -n "${BRANCH:-}" && "$(git rev-parse --abbrev-ref HEAD)" != "$BRANCH" ]]; then
if [[ -z "${GITHUB_BASE_REF:-}" && -n "${BRANCH:-}" && "$(git rev-parse --abbrev-ref HEAD)" != "$BRANCH" ]]; then
echo "Checking if branch $BRANCH exists."
if ! git show-ref --verify --quiet "refs/heads/$BRANCH"; then
if git show-ref --verify --quiet "refs/remotes/origin/$BRANCH"; then
Expand Down