phpbb/.github/workflows/check_merge_to_master.yml
2024-09-28 16:14:22 +01:00

60 lines
2.4 KiB
YAML

name: Check merge to master
on:
pull_request_target:
types: [ opened, synchronize, reopened ]
branches:
- 3.3.x
jobs:
merge-check:
if: github.event_name == 'pull_request_target' && github.event.pull_request.base.ref == '3.3.x'
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Ensure full history is fetched
- name: Set up Git user
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"
- name: Fetch all branches
run: git fetch origin
- name: Simulate merging PR into 3.3.x
id: simulate_merge
run: |
git checkout 3.3.x
git fetch origin pull/${{ github.event.pull_request.number }}/head
git merge --no-ff FETCH_HEAD || exit 1
- name: Attempt to merge updated 3.3.x into master
id: merge_master
run: |
git checkout master
if git merge --no-ff 3.3.x --no-commit; then
echo "mergeable=true" >> $GITHUB_OUTPUT
else
echo "mergeable=false" >> $GITHUB_OUTPUT
git merge --abort
fi
- name: Post comment on PR
if: always() # Ensure this step always runs, regardless of merge result
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
The attempt to merge branch `3.3.x` into `master` has completed after considering the changes in this PR.
- Merge result: ${{ steps.merge_master.outputs.mergeable == 'true' && 'Success ✅' || 'Conflict ❌' }}
${{ steps.merge_master.outputs.mergeable == 'true' && 'This PR is ready to be merged.' || 'A separate PR will be needed to merge `3.3.x` into `master`.' }}
- name: Mark job as succeeded
if: always()
run: echo "Merge check completed. Ignoring the result to avoid failed status."