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
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -343,6 +343,7 @@ As seen above, we have two steps. One for a noop deploy, and one for a regular d
343
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 |
344
344
| `commit_verified` | The string `"true"` if the commit is verified, otherwise `"false"` |
345
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 |
@@ -1034,6 +1035,11 @@ test('runs prechecks and finds that the IssueOps command is valid for a branch d
1034
1035
sha: 'abcde12345',
1035
1036
isFork: true
1036
1037
})
1038
+
1039
+
expect(setOutputMock).not.toHaveBeenCalledWith(
1040
+
'non_default_target_branch_used',
1041
+
'true'
1042
+
)
1037
1043
})
1038
1044
1039
1045
test('runs prechecks and finds that the PR from a fork is targeting a non-default branch and rejects the deployment',async()=>{
@@ -1082,6 +1088,11 @@ test('runs prechecks and finds that the PR from a fork is targeting a non-defaul
1082
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.`,
1083
1089
status: false
1084
1090
})
1091
+
1092
+
expect(setOutputMock).toHaveBeenCalledWith(
1093
+
'non_default_target_branch_used',
1094
+
'true'
1095
+
)
1085
1096
})
1086
1097
1087
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()=>{
@@ -1137,6 +1148,11 @@ test('runs prechecks and finds that the PR from a fork is targeting a non-defaul
1137
1148
sha: 'abcde12345',
1138
1149
isFork: true
1139
1150
})
1151
+
1152
+
expect(setOutputMock).toHaveBeenCalledWith(
1153
+
'non_default_target_branch_used',
1154
+
'true'
1155
+
)
1140
1156
})
1141
1157
1142
1158
test('runs prechecks and finds that the PR is targeting a non-default branch and rejects the deployment',async()=>{
@@ -1185,9 +1201,14 @@ test('runs prechecks and finds that the PR is targeting a non-default branch and
1185
1201
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.`,
1186
1202
status: false
1187
1203
})
1204
+
1205
+
expect(setOutputMock).toHaveBeenCalledWith(
1206
+
'non_default_target_branch_used',
1207
+
'true'
1208
+
)
1188
1209
})
1189
1210
1190
-
test('runs prechecks and finds that the PR is targeting a non-default branch and allows the deployment based on the action config',async()=>{
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()=>{
1191
1212
octokit.graphql=jest.fn().mockReturnValue({
1192
1213
repository: {
1193
1214
pullRequest: {
@@ -1239,6 +1260,15 @@ test('runs prechecks and finds that the PR is targeting a non-default branch and
1239
1260
sha: 'abcde12345',
1240
1261
isFork: false
1241
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
+
)
1242
1272
})
1243
1273
1244
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
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -268,6 +268,8 @@ outputs:
268
268
description: 'The string "true" if the commit has a verified signature, otherwise "false"'
269
269
total_seconds:
270
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'
// If the PR is targeting a branch other than the default branch (and it is not a stable branch deploy) reject the deployment, unless the Action is explicitly configured to allow it
message=`### ⚠️ Cannot proceed with deployment\n\nThis pull request is attempting to merge into the \`${baseRef}\` 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.`
99
-
return{message: message,status: false}
108
+
return{
109
+
message: `### ⚠️ Cannot proceed with deployment\n\nThis pull request is attempting to merge into the \`${baseRef}\` 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.`,
110
+
status: false
111
+
}
112
+
}
113
+
114
+
if(
115
+
isNotStableBranchDeploy&&
116
+
nonDefaultTargetBranchUsed&&
117
+
nonDefaultDeploysAllowed&&
118
+
securityWarningsEnabled
119
+
){
120
+
core.warning(
121
+
`🚨 this pull request is attempting to merge into the \`${baseRef}\` branch which is not the default branch of this repository (\`${data.inputs.stable_branch}\`) - this action is potentially dangerous`
122
+
)
100
123
}
101
124
102
125
// Determine whether to use the ref or sha depending on if the PR is from a fork or not
0 commit comments