Merge core/v7.1 into docs #48
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: Auto Merge Core | |
| on: | |
| push: | |
| branches: | |
| - 'core/v7.1' | |
| run-name: "Merge ${{ github.ref_name }} into docs" | |
| jobs: | |
| merge_branches: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| runs-on: ubuntu-latest | |
| name: Merge ${{ github.ref_name }} into ${{ matrix.branch }} | |
| strategy: | |
| matrix: | |
| branch: [unreal/v2.3] | |
| outputs: | |
| success_branches: ${{ steps.aggregate.outputs.success_branches }} | |
| conflicted_branches: ${{ steps.aggregate.outputs.conflicted_branches }} | |
| conflict_pr_urls: ${{ steps.aggregate.outputs.conflict_pr_urls }} | |
| steps: | |
| - name: Checkout target branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ matrix.branch }} | |
| token: ${{ secrets.DOCS_PAT }} | |
| fetch-depth: 0 | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Attempt merge | |
| id: merge | |
| run: | | |
| git fetch origin ${{ github.ref_name }} | |
| # Try a normal squash merge | |
| if git merge origin/${{ github.ref_name }} --squash; then | |
| git commit -m "Squash merge ${{ github.ref_name }} into ${{ matrix.branch }}" | |
| git push origin ${{ matrix.branch }} | |
| echo "status=success" >> $GITHUB_OUTPUT | |
| else | |
| # Merge conflict: retry with 'theirs' | |
| git reset --hard HEAD | |
| git merge origin/${{ github.ref_name }} --squash -X theirs | |
| if ! git diff --quiet; then | |
| git commit -m "Squash merge ${{ github.ref_name }} into ${{ matrix.branch }}" | |
| fi | |
| echo "status=conflict" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v7 | |
| id: create_pr | |
| if: steps.merge.outputs.status == 'conflict' | |
| with: | |
| token: ${{ secrets.DOCS_PAT }} | |
| title: "Merge ${{ github.ref_name }} into ${{ matrix.branch }} (Conflicts)" | |
| body: The ${{ github.ref_name }} branch was unable to merge into ${{ matrix.branch }}. Please review the changes. | |
| branch: merge-${{ github.ref_name }}-into-${{ matrix.branch }} | |
| delete-branch: true | |
| base: ${{ matrix.branch }} | |
| labels: bot | |
| - name: Collect PR URL | |
| id: collect_pr | |
| run: | | |
| conflict_pr_urls="" | |
| if [ "${{ steps.merge.outputs.status }}" = "conflict" ]; then | |
| safe_branch=$(echo "${{ matrix.branch }}" | tr '/' '_') | |
| pr_url="${{ steps.create_pr.outputs.pull-request-url }}" | |
| echo "${safe_branch}=${pr_url}" >> $GITHUB_OUTPUT | |
| conflict_pr_urls="$safe_branch=$pr_url" | |
| fi | |
| echo "conflict_pr_urls=${conflict_pr_urls}" >> $GITHUB_OUTPUT | |
| - name: Aggregate results | |
| id: aggregate | |
| run: | | |
| success_list="" | |
| conflict_list="" | |
| conflict_urls="" | |
| if [ "${{ steps.merge.outputs.status }}" = "success" ]; then | |
| success_list="${{ matrix.branch }}" | |
| elif [ "${{ steps.merge.outputs.status }}" = "conflict" ]; then | |
| conflict_list="${{ matrix.branch }}" | |
| conflict_urls="${{ steps.collect_pr.outputs.conflict_pr_urls }}" | |
| fi | |
| echo "success_branches=${success_list}" >> $GITHUB_OUTPUT | |
| echo "conflicted_branches=${conflict_list}" >> $GITHUB_OUTPUT | |
| echo "conflict_pr_urls=${conflict_urls}" >> $GITHUB_OUTPUT | |
| notify_slack: | |
| runs-on: ubuntu-latest | |
| needs: merge_branches | |
| steps: | |
| - name: Send Slack Summary | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DOCS_CHANNEL_URL }} | |
| SUCCESS: ${{ needs.merge_branches.outputs.success_branches }} | |
| CONFLICT: ${{ needs.merge_branches.outputs.conflicted_branches }} | |
| PR_URLS: ${{ needs.merge_branches.outputs.conflict_pr_urls }} | |
| run: | | |
| # If both are empty, do nothing | |
| if [ -z "$CONFLICT" ]; then | |
| echo "No conflicts — skipping Slack notification." | |
| exit 0 | |
| fi | |
| SUCCESS_MSG=$( [ -n "$SUCCESS" ] && echo $'Success:\n• '"$SUCCESS" || echo "Success: None" ) | |
| if [ -n "$CONFLICT" ]; then | |
| CONFLICT_MSG="Conflicts:" | |
| IFS=',' read -ra BRANCHES <<< "$CONFLICT" | |
| for b in "${BRANCHES[@]}"; do | |
| key="${b//\//_}" # replace / with _ | |
| url=$(echo "$PR_URLS" | grep "^$key=" | cut -d= -f2-) | |
| CONFLICT_MSG+=$'\n• '"$b: $url" | |
| done | |
| else | |
| CONFLICT_MSG="Conflicts: None" | |
| fi | |
| PAYLOAD=$(jq -n --arg success "$SUCCESS_MSG" --arg conflict "$CONFLICT_MSG" \ | |
| '{text: "${{ github.ref_name }} auto merge results:\n \($success)\n\($conflict)"}') | |
| curl -s -X POST "$SLACK_WEBHOOK_URL" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$PAYLOAD" |