name: Update Stable Branch from Main on Latest Release on: release: types: [released] permissions: contents: write jobs: update-stable-branch: name: Update Stable Branch from Main runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Configure Git run: | git config user.name "GitHub Actions Bot" git config user.email "github-actions[bot]@users.noreply.github.com" - name: Fetch latest main and stable branches run: | git fetch origin main:main git fetch origin stable:stable || echo "Stable branch not found remotely, will create." - name: Get latest main commit SHA id: get_main_sha run: echo "MAIN_SHA=$(git rev-parse main)" >> $GITHUB_ENV - name: Check out stable branch run: | if git show-ref --verify --quiet refs/heads/stable; then git checkout stable git pull origin stable # Sync with remote stable if it exists else echo "Creating local stable branch based on main HEAD." git checkout -b stable ${{ env.MAIN_SHA }} fi - name: Reset stable branch to latest main run: git reset --hard ${{ env.MAIN_SHA }} - name: Force push stable branch run: git push origin stable --force