File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Auto-Merge Master to Sync
2+ on :
3+ push :
4+ branches :
5+ - master
6+
7+ permissions :
8+ contents : write # Required to push to the sync branch
9+
10+ jobs :
11+ merge-master-to-sync :
12+ runs-on : ubuntu-latest
13+ steps :
14+ - name : Checkout repository
15+ uses : actions/checkout@v4
16+ with :
17+ fetch-depth : 0 # Fetches all history for all branches
18+
19+ - name : Setup Git User
20+ run : |
21+ git config user.name "github-actions[bot]"
22+ git config user.email "github-actions[bot]@users.noreply.github.com"
23+
24+ - name : Merge Master into Sync
25+ run : |
26+ git checkout sync
27+ git merge origin/master --no-edit
28+ git push origin sync
Original file line number Diff line number Diff line change 1+ name : Auto-Create PR from Sync to Master
2+ on :
3+ push :
4+ branches :
5+ - sync
6+
7+ permissions :
8+ pull-requests : write # Required to create the PR
9+ contents : read
10+
11+ jobs :
12+ create-pr :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Checkout repository
16+ uses : actions/checkout@v4
17+
18+ - name : Create Pull Request
19+ env :
20+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
21+ run : |
22+ # Check if a PR already exists to prevent duplicate errors
23+ PR_EXISTS=$(gh pr list --base master --head sync --state open --json number --jq 'length')
24+
25+ if [ "$PR_EXISTS" -eq "0" ]; then
26+ gh pr create \
27+ --base master \
28+ --head sync \
29+ --title "Sync: Customer updates to Master" \
30+ --body "Automated PR to merge overnight updates from the customer's \`sync\` branch into \`master\`."
31+ echo "Pull request created successfully."
32+ else
33+ echo "PR already exists. The new commits from this push are automatically added to the open PR."
34+ fi
You can’t perform that action at this time.
0 commit comments