diff --git a/.github/workflows/macos_action_test.yml b/.github/workflows/macos_action_test.yml deleted file mode 100644 index 4043d7f..0000000 --- a/.github/workflows/macos_action_test.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Action test on MacOS - -on: - pull_request: - branches: [main] - workflow_dispatch: - -permissions: - contents: read - pull-requests: write - -jobs: - macos-min: - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: ./ - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - macos-max: - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: ./ - with: - pr_title: "Pulling ${{ github.ref }} into main" - pr_body: "An automated PR" - pr_reviewer: "GuillaumeFalourd" - pr_assignee: "GuillaumeFalourd" - pr_label: "test" - pr_milestone: "Milestone 1" - pr_draft: true - pr_allow_empty: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..c5effe1 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,47 @@ +name: Action test +on: + pull_request: + branches: [main] + workflow_dispatch: +permissions: + contents: read + pull-requests: write + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + test: + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: ./ + name: test-min + if: failure() || success() + - uses: ./ + name: test-title-only + if: failure() || success() + with: + pr_title: "Pulling ${{ github.ref_name }} into main" + - uses: ./ + name: test-body-only + if: failure() || success() + with: + pr_body: "Pulling ${{ github.ref_name }} into main" + - uses: ./ + name: test-max + if: failure() || success() + with: + pr_title: "Pulling ${{ github.ref }} into main" + pr_body: "An automated PR" + pr_reviewer: "GuillaumeFalourd" + pr_assignee: "GuillaumeFalourd" + pr_label: "test" + pr_milestone: "Milestone 1" + pr_draft: true + pr_allow_empty: true diff --git a/.github/workflows/ubuntu_action_test.yml b/.github/workflows/ubuntu_action_test.yml deleted file mode 100644 index e3096e3..0000000 --- a/.github/workflows/ubuntu_action_test.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Action test on Ubuntu - -on: - pull_request: - branches: [main] - workflow_dispatch: - -permissions: - contents: read - pull-requests: write - -jobs: - ubuntu-min: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: ./ - id: pr - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: echo -e "Output of pr job is:\n${{ tojson(steps.pr.outputs) }}" - - ubuntu-max: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: ./ - id: pr - with: - pr_title: "Pulling ${{ github.ref_name }} into main" - pr_body: "An automated PR" - pr_reviewer: "GuillaumeFalourd" - pr_assignee: "GuillaumeFalourd" - pr_label: "test" - pr_milestone: "Milestone 1" - pr_draft: true - pr_allow_empty: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: echo -e "Output of pr job is:\n${{ tojson(steps.pr.outputs) }}" diff --git a/.github/workflows/windows_action_test.yml b/.github/workflows/windows_action_test.yml deleted file mode 100644 index 70a0fd9..0000000 --- a/.github/workflows/windows_action_test.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Action test on Windows - -on: - pull_request: - branches: [main] - workflow_dispatch: - -permissions: - contents: read - pull-requests: write - -jobs: - windows-min: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: ./ - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - windows-max: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: ./ - with: - pr_title: "Pulling ${{ github.ref }} into main" - pr_body: "An automated PR" - pr_reviewer: "GuillaumeFalourd" - pr_assignee: "GuillaumeFalourd" - pr_label: "test" - pr_milestone: "Milestone 1" - pr_draft: true - pr_allow_empty: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/action.yml b/action.yml index 042b000..55b8928 100644 --- a/action.yml +++ b/action.yml @@ -183,14 +183,11 @@ runs: declare -a COMMAND COMMAND+=(gh pr create --base $DESTINATION_BRANCH --head $SOURCE_BRANCH --no-maintainer-edit) - if [[ ! -z "${INPUT_PR_TITLE}" ]]; then - COMMAND+=(--title "${INPUT_PR_TITLE}") - else + if [[ -z "${INPUT_PR_TITLE}" ]] && [[ -z "${INPUT_PR_BODY}" ]]; then COMMAND+=(--fill) - fi - - if [[ ! -z "${INPUT_PR_BODY}" ]]; then - COMMAND+=(--body "${INPUT_PR_BODY}") + else + [[ -n "${INPUT_PR_TITLE}" ]] && COMMAND+=(--title "${INPUT_PR_TITLE}") || COMMAND+=(--fill) + [[ -n "${INPUT_PR_BODY}" ]] && COMMAND+=(--body "${INPUT_PR_BODY}") || COMMAND+=(--fill) fi if [[ ! -z "${INPUT_PR_REVIEWER}" ]]; then @@ -239,6 +236,7 @@ runs: if [[ "$pr_command_exit_code" != "0" && "$pr_already_exists" -eq 0 ]]; then echo_error "Failed to create pull request. Exit code: $pr_command_exit_code. Error: $pr_command_error" + exit $pr_command_exit_code else # assume that if we got here, a PR was created or exists echo_success "Pull request created or exists: $pr_url" @@ -257,7 +255,6 @@ runs: echo "::endgroup::" - branding: icon: 'git-pull-request' color: 'blue'