Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions promote/promote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ promote_mono() {
}

github_notify_promotion() {
local check_context="$1"
local project_version longDescription shortDescription buildUrl githubApiUrl
project_version="$PROJECT_VERSION"
longDescription="Latest promoted build of '${project_version}' from branch '${GITHUB_REF}'"
Expand All @@ -159,7 +160,7 @@ github_notify_promotion() {
"state": "success",
"target_url": "$buildUrl",
"description": "$shortDescription",
"context": "repox-${GITHUB_REF_NAME}"
"context": "$check_context"
}
EOF
}
Expand Down Expand Up @@ -224,7 +225,8 @@ promote() {
echo "::endgroup::"

echo "::group::Notify GitHub"
github_notify_promotion
github_notify_promotion "repox-${BUILD_NAME}-${GITHUB_REF_NAME}"
github_notify_promotion "repox-${GITHUB_REF_NAME}" # DEPRECATED - backward compatibility
echo "::endgroup::"

generate_workflow_summary
Expand Down
9 changes: 5 additions & 4 deletions spec/promote_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Describe 'promote/promote.sh'
export PROMOTE_PULL_REQUEST="true"
When run script promote/promote.sh
The status should be success
The lines of stdout should equal 20
The lines of stdout should equal 21
The line 1 should equal "::group::Check tools"
The line 2 should include "gh"
The line 3 should include "gh"
Expand All @@ -117,7 +117,8 @@ Describe 'promote/promote.sh'
The line 17 should equal "::endgroup::"
The line 18 should equal "::group::Notify GitHub"
The line 19 should include "gh api -X POST"
The line 20 should equal "::endgroup::"
The line 20 should include "gh api -X POST"
The line 21 should equal "::endgroup::"
End

It 'skips promotion on pull_request when promotion is disabled'
Expand Down Expand Up @@ -351,9 +352,9 @@ Describe 'jfrog_promote()'
End

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