-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollect-artifacts-url.sh
More file actions
executable file
·65 lines (49 loc) · 1.65 KB
/
Copy pathcollect-artifacts-url.sh
File metadata and controls
executable file
·65 lines (49 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
set -euo pipefail
REPOS=(EN PT-BR DE ES FR IT JA KO PL RU ZH)
WORKFLOW="${WORKFLOW:-main.yml}"
GH_TOKEN="${GH_TOKEN:?GH_TOKEN is required}"
SLACK_WEBHOOK_URL="${SLACK_WEBHOOK_URL:?SLACK_WEBHOOK_URL is required}"
RESULTS=""
echo "🔍 Collecting localisation build results..."
for LANG in "${REPOS[@]}"; do
REPO="YoYoGames/GameMaker-Manual-$LANG"
echo "➡️ Checking $REPO"
# Get latest workflow run
RUN_JSON=$(curl -s -H "Authorization: token $GH_TOKEN" \
"https://api.github.com/repos/$REPO/actions/workflows/$WORKFLOW/runs?per_page=1")
RUN_ID=$(echo "$RUN_JSON" | jq -r '.workflow_runs[0].id')
STATUS=$(echo "$RUN_JSON" | jq -r '.workflow_runs[0].status')
CONCLUSION=$(echo "$RUN_JSON" | jq -r '.workflow_runs[0].conclusion')
# Fallback safety
if [[ "$RUN_ID" == "null" || -z "$RUN_ID" ]]; then
RESULTS+=":warning: $LANG → No run found
"
continue
fi
ARTIFACT_URL="https://github.com/$REPO/actions/runs/$RUN_ID#artifacts"
# Format status
if [[ "$CONCLUSION" == "success" ]]; then
RESULTS+=":white_check_mark: $LANG → <$ARTIFACT_URL|Artifacts>
"
elif [[ "$CONCLUSION" == "failure" ]]; then
RESULTS+=":x: $LANG → <$ARTIFACT_URL|Artifacts>
"
else
RESULTS+=":warning: $LANG → <$ARTIFACT_URL|Artifacts> (status: $STATUS)
"
fi
done
# -----------------------------
# 📦 Build Slack message safely
# -----------------------------
MSG=$(cat <<EOF
:package: *Localisation Build Artifacts*
$RESULTS
EOF
)
echo "📤 Sending Slack notification..."
curl -s -X POST -H 'Content-type: application/json' \
--data "$(jq -n --arg text "$MSG" '{text: $text}')" \
"$SLACK_WEBHOOK_URL"
echo "✅ Done"