Update onpr_automerge.yaml

This commit is contained in:
Alexandre
2024-02-28 10:50:40 +01:00
committed by GitHub
parent ed97ffa7d3
commit 2d0e32b024

View File

@@ -1,11 +1,12 @@
# yamllint disable rule:line-length # yamllint disable rule:line-length
# shellcheck disable=SC2043 # shellcheck disable=SC2043
--- ---
name: PR automerge name: automerge
on: on:
pull_request: pull_request:
types: types:
- labeled - labeled
- unlabeled
- synchronize - synchronize
- opened - opened
- edited - edited
@@ -15,35 +16,16 @@ on:
pull_request_review: pull_request_review:
types: types:
- submitted - submitted
check_suite:
types:
- completed
status: {}
jobs: jobs:
auto-merge: automerge:
if: ${{ (github.event.issue.pull_request) && (contains(github.event.comment.body, '/automerge')) }} # <--- The other way to compare if it's on a PR or on an issue
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: - id: automerge
- name: Check PR title name: automerge
run: | uses: "pascalgn/automerge-action@v0.16.2"
title="${{ github.event.pull_request.title }}" env:
if [[ "$title" == *"auto_merge"* ]]; then GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
echo "PR title contains auto_merge"
echo "AUTO_MERGE=true" >> $GITHUB_ENV
else
echo "PR title does not contain automerge"
echo "AUTO_MERGE=false" >> $GITHUB_ENV
fi
- name: Check PR status
if: env.AUTO_MERGE == 'true'
run: |
#status="${{ github.event.check_suite.conclusion }}"
#if [[ "$status" == "success" ]]; then
echo "All checks are successful"
echo "PR_STATUS=true" >> $GITHUB_ENV
#else
# echo "Some checks are not successful"
# echo "PR_STATUS=false" >> $GITHUB_ENV
#fi
- name: Merge PR
if: env.PR_STATUS == 'true'
run: |
curl -X PUT -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge