You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2026-04-26 20:43:22 +02:00
74 lines
2.5 KiB
YAML
74 lines
2.5 KiB
YAML
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 |