-
Notifications
You must be signed in to change notification settings - Fork 2
34 lines (30 loc) · 1.04 KB
/
sync-auto-pr.yml
File metadata and controls
34 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
name: Auto-Create PR from Sync to Master
on:
push:
branches:
- sync
permissions:
pull-requests: write # Required to create the PR
contents: read
jobs:
create-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Check if a PR already exists to prevent duplicate errors
PR_EXISTS=$(gh pr list --base master --head sync --state open --json number --jq 'length')
if [ "$PR_EXISTS" -eq "0" ]; then
gh pr create \
--base master \
--head sync \
--title "Sync: Customer updates to Master" \
--body "Automated PR to merge overnight updates from the customer's \`sync\` branch into \`master\`."
echo "Pull request created successfully."
else
echo "PR already exists. The new commits from this push are automatically added to the open PR."
fi