forked from open-edge-platform/edge-ai-suites
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (74 loc) · 2.99 KB
/
siv-weekly-tag.yaml
File metadata and controls
87 lines (74 loc) · 2.99 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: SIV Weekly Build Tagging
on:
schedule:
- cron: '0 15 * * 2' # Every Tuesday at 15:00 UTC
workflow_dispatch:
permissions: {}
jobs:
create-tag:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Get latest commit SHA
id: get-sha
run: |
echo "🔍 Getting latest commit SHA from main branch..."
RESPONSE=$(curl -s -w "%{http_code}" -o commit.json \
-H "Authorization: Bearer ${{ secrets.SIV_USER_TOKEN_GH }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/commits/main)
HTTP_CODE="${RESPONSE: -3}"
if [ "$HTTP_CODE" -eq 200 ]; then
COMMIT_SHA=$(jq -r '.sha' commit.json)
echo "✅ Successfully retrieved commit SHA: $COMMIT_SHA"
echo "sha=$COMMIT_SHA" >> $GITHUB_OUTPUT
else
echo "❌ Failed to get commit SHA. HTTP Code: $HTTP_CODE"
echo "Response:"
cat commit.json
exit 1
fi
- name: Create lightweight tag via API
run: |
TAG_NAME="${{ vars.SIV_WEEKLY_BUILD_PREFIX }}-$(date +'%Y%m%d')"
COMMIT_SHA="${{ steps.get-sha.outputs.sha }}"
echo "🚀 Creating tag: $TAG_NAME"
echo "📍 Target commit: $COMMIT_SHA"
if [ "$COMMIT_SHA" = "" ] || [ "$COMMIT_SHA" = "null" ]; then
echo "❌ Invalid commit SHA: $COMMIT_SHA"
exit 1
fi
RESPONSE=$(curl -s -w "%{http_code}" -o tag.json \
-H "Authorization: Bearer ${{ secrets.SIV_USER_TOKEN_GH }}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/json" \
-X POST \
https://api.github.com/repos/${{ github.repository }}/git/refs \
-d "{
\"ref\": \"refs/tags/${TAG_NAME}\",
\"sha\": \"${COMMIT_SHA}\"
}")
HTTP_CODE="${RESPONSE: -3}"
if [ "$HTTP_CODE" -eq 201 ]; then
printf "\n"
printf "✅ Weekly Build Tag Created Successfully!\n"
printf "==========================================\n"
printf "📌 Tag Name: %s\n" "${TAG_NAME}"
printf "🔗 Commit SHA: %s\n" "${COMMIT_SHA}"
printf "📁 Repository: %s\n" "${{ github.repository }}"
printf "⏰ Created: %s\n" "$(date -u '+%Y-%m-%d %H:%M:%S UTC')"
printf "🌐 View Online: https://github.com/%s/releases/tag/%s\n" "${{ github.repository }}" "${TAG_NAME}"
printf "\n"
echo "📋 API Response:"
cat tag.json | jq '.'
else
printf "\n"
printf "❌ Failed to create tag!\n"
printf "========================\n"
printf "HTTP Code: %s\n" "$HTTP_CODE"
printf "Response:\n"
cat tag.json
printf "\n"
exit 1
fi