Skip to content

Commit 008394a

Browse files
committed
Refactor GitHub status context naming to include environment and stage name for improved clarity
1 parent 3190d14 commit 008394a

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

azure/components/update-github-status.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,22 @@ steps:
3939
4040
BUILD_RESULTS_URL="$(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=results"
4141
42+
4243
if [[ "$(NOTIFY_COMMIT_SHA)" =~ ^[0-9a-f]+$ ]]; then
43-
context_suffix="[${environment}]"
44-
if [[ -n "${stage_name}" ]]; then
45-
context_suffix="[${environment}][${stage_name}]"
44+
if [[ -n "${environment}" && -n "${stage_name}" ]]; then
45+
context_name="$(Build.DefinitionName)[${environment}][${stage_name}]"
46+
elif [[ -n "${environment}" ]]; then
47+
context_name="$(Build.DefinitionName)[${environment}]"
48+
else
49+
context_name="$(Build.DefinitionName)"
4650
fi
4751
4852
echo "Reporting state ${{ parameters.state }} to ${NOTIFY_GITHUB_REPOSITORY}"
4953
echo "##[debug] Hitting https://api.github.com/repos/${NOTIFY_GITHUB_REPOSITORY}/statuses/$(NOTIFY_COMMIT_SHA)"
5054
5155
payload=$(jq -nc \
5256
--arg state "${{ parameters.state }}" \
53-
--arg context "$(Build.DefinitionName)${context_suffix}" \
57+
--arg context "$context_name" \
5458
--arg description "${description}" \
5559
--arg target_url "${BUILD_RESULTS_URL}" \
5660
'{state: $state, context: $context, description: $description, target_url: $target_url}')

0 commit comments

Comments
 (0)