Skip to content

Commit c15f373

Browse files
authored
BUILD-10457 Parameterize check context in github_notify_promotion (#217)
Make check_context a function parameter and call github_notify_promotion twice: once with the new BUILD_NAME-scoped context for unique parallel checks, and once with the legacy repox-${GITHUB_REF_NAME} context for backward compatibility.
1 parent 94416c8 commit c15f373

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

promote/promote.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ promote_mono() {
148148
}
149149

150150
github_notify_promotion() {
151+
local check_context="$1"
151152
local project_version longDescription shortDescription buildUrl githubApiUrl
152153
project_version="$PROJECT_VERSION"
153154
longDescription="Latest promoted build of '${project_version}' from branch '${GITHUB_REF}'"
@@ -159,7 +160,7 @@ github_notify_promotion() {
159160
"state": "success",
160161
"target_url": "$buildUrl",
161162
"description": "$shortDescription",
162-
"context": "repox-${GITHUB_REF_NAME}"
163+
"context": "$check_context"
163164
}
164165
EOF
165166
}
@@ -224,7 +225,8 @@ promote() {
224225
echo "::endgroup::"
225226

226227
echo "::group::Notify GitHub"
227-
github_notify_promotion
228+
github_notify_promotion "repox-${BUILD_NAME}-${GITHUB_REF_NAME}"
229+
github_notify_promotion "repox-${GITHUB_REF_NAME}" # DEPRECATED - backward compatibility
228230
echo "::endgroup::"
229231

230232
generate_workflow_summary

spec/promote_spec.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Describe 'promote/promote.sh'
9797
export PROMOTE_PULL_REQUEST="true"
9898
When run script promote/promote.sh
9999
The status should be success
100-
The lines of stdout should equal 20
100+
The lines of stdout should equal 21
101101
The line 1 should equal "::group::Check tools"
102102
The line 2 should include "gh"
103103
The line 3 should include "gh"
@@ -117,7 +117,8 @@ Describe 'promote/promote.sh'
117117
The line 17 should equal "::endgroup::"
118118
The line 18 should equal "::group::Notify GitHub"
119119
The line 19 should include "gh api -X POST"
120-
The line 20 should equal "::endgroup::"
120+
The line 20 should include "gh api -X POST"
121+
The line 21 should equal "::endgroup::"
121122
End
122123

123124
It 'skips promotion on pull_request when promotion is disabled'
@@ -351,9 +352,9 @@ Describe 'jfrog_promote()'
351352
End
352353

353354
Describe 'github_notify_promotion()'
354-
It 'calls gh api with correct parameters'
355+
It 'calls gh api with the provided check context'
355356
export PROJECT_VERSION="1.2.3"
356-
When call github_notify_promotion
357+
When call github_notify_promotion "repox-dummy-project-dummy-branch"
357358
The output should include "gh api -X POST -H X-GitHub-Api-Version: 2022-11-28"
358359
The output should include "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA"
359360
The output should include "-H Content-Type: application/json --input -"

0 commit comments

Comments
 (0)