You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+2
Original file line number
Diff line number
Diff line change
@@ -300,6 +300,7 @@ As seen above, we have two steps. One for a noop deploy, and one for a regular d
300
300
| `skip_successful_deploy_labels_if_approved` | `false` | `"false"` | Whether or not the post run logic should skip adding successful deploy labels if the pull request is approved. This can be useful if you add a label such as "ready-for-review" after a `.deploy` completes but want to skip adding that label in situations where the pull request is already approved. |
301
301
| `enforced_deployment_order` | `false` | `""` | A comma separated list of environments that must be deployed in a specific order. Example: `"development,staging,production"`. If this is set then you cannot deploy to latter environments unless the former ones have a successful and active deployment on the latest commit first - See the [enforced deployment order docs](./docs/enforced-deployment-order.md) for more details |
302
302
| `use_security_warnings` | `false` | `"true"` | Whether or not to leave security related warnings in log messages during deployments. Default is `"true"` |
303
+
| `allow_non_default_target_branch_deployments` | `false` | `"false"` | Whether or not to allow deployments of pull requests that target a branch other than the default branch (aka stable branch) as their merge target. By default, this Action would reject the deployment of a branch named `feature-branch` if it was targeting `foo` instead of `main` (or whatever your default branch is). This option allows you to override that behavior and be able to deploy any branch in your repository regardless of the target branch. This option is potentially unsafe and should be used with caution as most default branches contain branch protection rules. Often times non-default branches do not contain these same branch protection rules. Follow along in this [issue thread](https://github.com/github/branch-deploy/issues/340) to learn more. |
303
304
304
305
## Outputs 📤
305
306
@@ -342,6 +343,7 @@ As seen above, we have two steps. One for a noop deploy, and one for a regular d
342
343
| `needs_to_be_deployed` | A comma separated list of environments that need successful and active deployments before the current environment (that was requested) can be deployed. This output is tied to the `enforced_deployment_order` input option - See the [enforced deployment order docs](./docs/enforced-deployment-order.md) for more details |
343
344
| `commit_verified` | The string `"true"` if the commit is verified, otherwise `"false"` |
344
345
| `total_seconds` | The total number of seconds that the deployment took to complete (Integer) |
346
+
| `non_default_target_branch_used` | The string `"true"` if the pull request is targeting a branch other than the default branch (aka stable branch) for the merge, otherwise unset |
@@ -1033,6 +1035,11 @@ test('runs prechecks and finds that the IssueOps command is valid for a branch d
1033
1035
sha: 'abcde12345',
1034
1036
isFork: true
1035
1037
})
1038
+
1039
+
expect(setOutputMock).not.toHaveBeenCalledWith(
1040
+
'non_default_target_branch_used',
1041
+
'true'
1042
+
)
1036
1043
})
1037
1044
1038
1045
test('runs prechecks and finds that the PR from a fork is targeting a non-default branch and rejects the deployment',async()=>{
@@ -1081,6 +1088,187 @@ test('runs prechecks and finds that the PR from a fork is targeting a non-defaul
1081
1088
message: `### ⚠️ Cannot proceed with deployment\n\nThis pull request is attempting to merge into the \`some-other-branch\` branch which is not the default branch of this repository (\`${data.inputs.stable_branch}\`). This deployment has been rejected since it could be dangerous to proceed.`,
1082
1089
status: false
1083
1090
})
1091
+
1092
+
expect(setOutputMock).toHaveBeenCalledWith(
1093
+
'non_default_target_branch_used',
1094
+
'true'
1095
+
)
1096
+
})
1097
+
1098
+
test('runs prechecks and finds that the PR from a fork is targeting a non-default branch and allows it based on the action config',async()=>{
message: `### ⚠️ Cannot proceed with deployment\n\nThis pull request is attempting to merge into the \`not-main\` branch which is not the default branch of this repository (\`${data.inputs.stable_branch}\`). This deployment has been rejected since it could be dangerous to proceed.`,
1202
+
status: false
1203
+
})
1204
+
1205
+
expect(setOutputMock).toHaveBeenCalledWith(
1206
+
'non_default_target_branch_used',
1207
+
'true'
1208
+
)
1209
+
})
1210
+
1211
+
test('runs prechecks and finds that the PR is targeting a non-default branch and allows the deployment based on the action config and logs a warning',async()=>{
message: `✅ PR is approved and all CI checks passed`,
1257
+
status: true,
1258
+
noopMode: false,
1259
+
ref: 'test-ref',
1260
+
sha: 'abcde12345',
1261
+
isFork: false
1262
+
})
1263
+
1264
+
expect(setOutputMock).toHaveBeenCalledWith(
1265
+
'non_default_target_branch_used',
1266
+
'true'
1267
+
)
1268
+
1269
+
expect(warningMock).toHaveBeenCalledWith(
1270
+
`🚨 this pull request is attempting to merge into the \`not-main\` branch which is not the default branch of this repository (\`${data.inputs.stable_branch}\`) - this action is potentially dangerous`
1271
+
)
1084
1272
})
1085
1273
1086
1274
test('runs prechecks and finds that the IssueOps command is valid for a branch deployment and is from a forked repository and the PR is approved but CI is failing and it is a noop',async()=>{
Copy file name to clipboardexpand all lines: action.yml
+6
Original file line number
Diff line number
Diff line change
@@ -189,6 +189,10 @@ inputs:
189
189
description: 'Whether or not to leave security related warnings in log messages during deployments. Default is "true"'
190
190
required: false
191
191
default: "true"
192
+
allow_non_default_target_branch_deployments:
193
+
description: 'Whether or not to allow deployments of pull requests that target a branch other than the default branch (aka stable branch) as their merge target. By default, this Action would reject the deployment of a branch named "feature-branch" if it was targeting "foo" instead of "main" (or whatever your default branch is). This option allows you to override that behavior and be able to deploy any branch in your repository regardless of the target branch. This option is potentially unsafe and should be used with caution as most default branches contain branch protection rules. Often times non-default branches do not contain these same branch protection rules. Follow along in this issue thread to learn more https://github.com/github/branch-deploy/issues/340'
194
+
required: false
195
+
default: "false"
192
196
outputs:
193
197
continue:
194
198
description: 'The string "true" if the deployment should continue, otherwise empty - Use this to conditionally control if your deployment should proceed or not'
@@ -264,6 +268,8 @@ outputs:
264
268
description: 'The string "true" if the commit has a verified signature, otherwise "false"'
265
269
total_seconds:
266
270
description: 'The total number of seconds that the deployment took to complete (Integer)'
271
+
non_default_target_branch_used:
272
+
description: 'The string "true" if the pull request is targeting a branch other than the default branch (aka stable branch) for the merge, otherwise unset'
0 commit comments