Update Stable Branch on Latest Release Update #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Stable Branch on Latest Release Update | |
| on: | |
| workflow_dispatch: | |
| release: | |
| types: | |
| - published | |
| - edited | |
| - updated | |
| jobs: | |
| update-stable: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| actions: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configure Git user | |
| run: | | |
| git config --local user.email "vitaly.the.alpaca@gmail.com" | |
| git config --local user.name "Vitaly the Alpaca (bot)" | |
| - name: Update stable branch from latest release | |
| 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" | |
| git checkout -B stable | |
| git push --force origin stable | |
| echo "✅ Stable branch successfully updated to $LATEST_RELEASE ($COMMIT_SHA)" |