This commit is contained in:
Moritz Utcke
2025-04-28 17:18:45 -03:00
parent 4b9e7dda5f
commit 76bd0bb5dd

View File

@@ -33,33 +33,22 @@ jobs:
exit 1
fi
- name: Checkout staging and create branch
id: create_branch
run: |
git checkout -b auto-merge/staging-to-main origin/staging
git push origin auto-merge/staging-to-main
- name: Create PR from staging → main
- name: Create PR from staging to main
id: create_pr
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: auto-merge staging into main"
branch: auto-merge/staging-to-main
base: main
title: "Auto-merge staging into main"
body: |
This PR was created automatically by GitHub Actions.
It merges the latest `staging` into `main`.
draft: false
run: |
PR_URL=$(gh pr create --base main --head staging --title "Auto-merge staging into main" --body "This PR was created automatically by GitHub Actions. It merges the latest \`staging\` into \`main\`.")
echo "PR_URL=$PR_URL" >> $GITHUB_OUTPUT
PR_NUMBER=$(echo $PR_URL | awk -F'/' '{print $NF}')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable auto-merge on PR
if: steps.create_pr.outputs.pull-request-number != ''
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }}
merge-method: merge
if: steps.create_pr.outputs.PR_NUMBER != ''
run: |
gh pr merge ${{ steps.create_pr.outputs.PR_NUMBER }} --merge --auto
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify_failure: