blob: 5aa10ed5208b4465bd9488f58a6278af9ddaec81 [file]
name: Batch Release
on:
push:
branches:
- 'release-go_router-*'
- 'release-cupertino_ui-*'
- 'release-material_ui-*'
jobs:
release:
permissions:
# Release needs to push a tag back to the repo.
contents: write
uses: ./.github/workflows/reusable_release.yml
with:
is-batch-release: true
branch-name: '${{ github.ref_name }}'
secrets:
USER_NAME: ${{ secrets.USER_NAME }}
USER_EMAIL: ${{ secrets.USER_EMAIL }}
PUB_CREDENTIALS: ${{ secrets.PUB_CREDENTIALS }}
sync_to_main:
needs: release
if: github.repository_owner == 'flutter' && needs.release.result == 'success'
runs-on: ubuntu-latest
permissions:
# Need write permission to create PR.
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
fetch-depth: 0 # Fetch history to allow branch comparison
persist-credentials: false
- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.FLUTTERGITHUBBOT_TOKEN }}
run: |
gh auth setup-git
# 1. Fetch main so the runner can see the difference
git fetch origin main
# 2. Verify there are actually new commits to sync
# This prevents the "GraphQL: No commits between main..." error
COMMITS_COUNT=$(git rev-list --count origin/main..HEAD)
if [ "$COMMITS_COUNT" -eq "0" ]; then
echo "No new commits found on ${GITHUB_REF_NAME} compared to main. Nothing to sync."
exit 0
fi
# 3. Extract package name for label
BRANCH_NAME="${GITHUB_REF_NAME}"
TEMP="${BRANCH_NAME#release-}"
PACKAGE_NAME="${TEMP%-*}"
# 4. Check if PR already exists before creating
EXISTING_PR=$(gh pr list --head "${GITHUB_REF_NAME}" --base "main" --json number --jq '.[0].number')
if [ -n "$EXISTING_PR" ]; then
echo "A pull request for ${GITHUB_REF_NAME} already exists (#${EXISTING_PR})."
exit 0
fi
# 5. Create the PR directly
gh pr create \
--base "main" \
--head "${GITHUB_REF_NAME}" \
--title "Sync ${GITHUB_REF_NAME} to main" \
--body "This automated PR syncs the changes from the release branch ${GITHUB_REF_NAME} back to the main branch." \
--label "override: batch-${PACKAGE_NAME}"