forked from Bayselonarrend/OpenIntegrations
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (59 loc) · 2.53 KB
/
stable.yml
File metadata and controls
74 lines (59 loc) · 2.53 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
name: Update Stable Branch on Latest Release Update
on:
workflow_dispatch:
release:
types:
- published
- edited
jobs:
update-stable:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update stable branch from latest release via API
env:
TOKEN: ${{ secrets.TOKEN }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
EVENT_NAME: ${{ github.event_name }}
run: |
echo "🔍 Event type: $EVENT_NAME"
LATEST_RELEASE=$(curl -s -H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/releases/latest" | \
jq -r '.tag_name')
echo "Latest release tag: $LATEST_RELEASE"
if [ "$EVENT_NAME" = "release" ]; then
echo "Current release tag: $RELEASE_TAG"
if [ "$RELEASE_TAG" != "$LATEST_RELEASE" ]; then
echo "⚠️ This is not the latest release. Skipping stable branch update."
exit 0
fi
echo "✓ This is the latest release!"
else
echo "✓ Manual workflow dispatch - updating to latest release"
fi
echo "📦 Updating stable branch to release commit..."
git fetch --tags --force
git checkout "$LATEST_RELEASE"
COMMIT_SHA=$(git rev-parse HEAD)
echo "Release commit SHA: $COMMIT_SHA"
# Используем GitHub API для обновления ветки (обходит ограничения на workflow файлы)
echo "🔄 Updating stable branch via GitHub API..."
RESPONSE=$(curl -X PATCH \
-H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/git/refs/heads/stable" \
-d "{\"sha\":\"$COMMIT_SHA\",\"force\":true}")
echo "API Response: $RESPONSE"
# Проверяем успешность
if echo "$RESPONSE" | jq -e '.ref' > /dev/null; then
echo "✅ Stable branch successfully updated to $LATEST_RELEASE ($COMMIT_SHA)"
else
echo "❌ Failed to update stable branch"
echo "$RESPONSE"
exit 1
fi