Skip to content

Commit 08fbe6e

Browse files
chore(CI): gracefully handle creating milestone with existing name
closes bpmn-io/internal-docs#1052
1 parent 34d38bc commit 08fbe6e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

.github/workflows/CREATE_MILESTONE.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,22 @@ jobs:
2222
env:
2323
TITLE: ${{steps.getTitle.outputs.MILESTONE_NAME}}
2424
GH_TOKEN: ${{ github.token }}
25+
shell: bash
2526
run: |
26-
gh api \
27+
response=$(gh api \
2728
--method POST \
2829
/repos/${{ github.repository }}/milestones \
29-
-f "title=$TITLE" -f "state=open"
30+
-f "title=$TITLE" -f "state=open")
31+
32+
# if response has a errors[].code === "already_exists" in a JSON response, we do nothing
33+
if echo "$response" | jq -e '.errors | map(select(.code == "already_exists")) | length > 0' > /dev/null; then
34+
echo "Milestone $TITLE already exists, no action needed"
35+
# if there is .title === $TITLE in the response, we successfully created the milestone
36+
elif echo "$response" | jq -e ".title == \"$TITLE\"" >/dev/null; then
37+
echo "Milestone $TITLE created successfully"
38+
# otherwise, we print the error
39+
else
40+
echo "Error creating milestone $TITLE"
41+
echo $response
42+
exit 1
43+
fi

0 commit comments

Comments
 (0)