|
57 | 57 | base-branch: ${{ steps.set-base-branch.outputs.base-branch }} |
58 | 58 | target-branch: ${{ steps.set-target-branch.outputs.target-branch }} |
59 | 59 | target-branch-exists: ${{ steps.check-target-branch-exists.outputs.target-branch-exists }} |
| 60 | + pull-request-exists: ${{ steps.check-pull-request-exists.outputs.pull-request-exists }} |
60 | 61 | steps: |
61 | 62 | - name: 'Set target branch' |
62 | 63 | id: set-target-branch |
@@ -111,12 +112,34 @@ jobs: |
111 | 112 | echo "Base branch ${{ env.base-branch }} does exist." |
112 | 113 | base_branch_exists="true" |
113 | 114 | else |
114 | | - echo "TarBaseget branch ${{ env.base-branch }} does not exist." |
| 115 | + echo "Base branch ${{ env.base-branch }} does not exist." |
115 | 116 | base_branch_exists="false" |
116 | 117 | fi |
117 | 118 |
|
118 | 119 | echo "base-branch-exists=$base_branch_exists" >> $GITHUB_OUTPUT |
119 | 120 |
|
| 121 | + set -e |
| 122 | + - name: 'Check if pull request exists exists' |
| 123 | + id: check-pull-request-exists |
| 124 | + env: |
| 125 | + GH_TOKEN: ${{ github.token }} |
| 126 | + current-branch: ${{ github.ref_name }} |
| 127 | + target-branch: ${{ needs.workflow-variables.outputs.target-branch }} |
| 128 | + run: | |
| 129 | + set +e |
| 130 | +
|
| 131 | + pull_request_exists=$(echo gh pr list --head ${{ env.current-branch }} -base ${{ env.target-branch }} --state "open" --limit 1 --jq '.total_count') |
| 132 | +
|
| 133 | + if [[ $? -eq 0 ]]; then |
| 134 | + echo "Base branch ${{ env.base-branch }} does exist." |
| 135 | + $pull_request_exists="true" |
| 136 | + else |
| 137 | + echo "Base branch ${{ env.base-branch }} does not exist." |
| 138 | + $pull_request_exists="false" |
| 139 | + fi |
| 140 | +
|
| 141 | + echo "pull-request-exists=$pull_request_exists" >> $GITHUB_OUTPUT |
| 142 | +
|
120 | 143 | set -e |
121 | 144 |
|
122 | 145 | validate-promotion: |
|
0 commit comments