Merge pull request #165 from contentstack/development #1
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
| # Opens a PR from main → development after changes land on main (back-merge). | |
| name: Back-merge main to development | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| open-back-merge-pr: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Open back-merge PR if needed | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| git fetch origin development main | |
| MAIN_SHA=$(git rev-parse origin/main) | |
| DEV_SHA=$(git rev-parse origin/development) | |
| if [ "$MAIN_SHA" = "$DEV_SHA" ]; then | |
| echo "main and development are at the same commit; nothing to back-merge." | |
| exit 0 | |
| fi | |
| EXISTING=$(gh pr list --repo "${{ github.repository }}" \ | |
| --base development \ | |
| --head main \ | |
| --state open \ | |
| --json number \ | |
| --jq 'length') | |
| if [ "$EXISTING" -gt 0 ]; then | |
| echo "An open PR from main to development already exists; skipping." | |
| exit 0 | |
| fi | |
| gh pr create --repo "${{ github.repository }}" \ | |
| --base development \ | |
| --head main \ | |
| --title "chore: back-merge main into development" \ | |
| --body "Automated back-merge after changes landed on \`main\`. Review and merge to keep \`development\` in sync." | |
| echo "Created back-merge PR main → development." |