Skip to content

Commit 708989b

Browse files
authored
Merge pull request #163 from NREL/develop
auto sync develop from main
2 parents 855e3f9 + d011b10 commit 708989b

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

‎.github/workflows/sync-develop.yml‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Sync develop with main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
sync:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
timeout-minutes: 5
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Configure git
24+
run: |
25+
git config user.name "github-actions[bot]"
26+
git config user.email "github-actions[bot]@users.noreply.github.com"
27+
28+
- name: Fetch latest branches
29+
run: |
30+
git fetch origin main
31+
git fetch origin develop
32+
33+
- name: Create sync branch
34+
run: |
35+
git checkout -b sync/main-to-develop-${{ github.run_number }} origin/develop
36+
37+
- name: Merge main into sync branch
38+
id: merge
39+
run: |
40+
if git merge origin/main --no-edit; then
41+
echo "merge_success=true" >> $GITHUB_OUTPUT
42+
else
43+
echo "merge_success=false" >> $GITHUB_OUTPUT
44+
echo "Merge conflict detected. Manual resolution required."
45+
exit 1
46+
fi
47+
48+
- name: Push sync branch
49+
if: steps.merge.outputs.merge_success == 'true'
50+
run: |
51+
git push origin sync/main-to-develop-${{ github.run_number }}
52+
53+
- name: Create Pull Request
54+
if: steps.merge.outputs.merge_success == 'true'
55+
id: create_pr
56+
uses: peter-evans/create-pull-request@v6
57+
with:
58+
token: ${{ secrets.GITHUB_TOKEN }}
59+
branch: sync/main-to-develop-${{ github.run_number }}
60+
base: develop
61+
title: "Sync develop with main"
62+
body: |
63+
## Auto-generated sync PR
64+
65+
This PR syncs `develop` with the latest changes from `main`.
66+
67+
**Triggered by:** Push to `main` (commit: ${{ github.sha }})
68+
**Workflow run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
69+
70+
labels: |
71+
automated
72+
sync
73+
draft: false
74+
75+
- name: Enable auto-merge
76+
if: steps.merge.outputs.merge_success == 'true'
77+
run: |
78+
PR_URL="${{ steps.create_pr.outputs.pull-request-url }}"
79+
PR_NUMBER=$(echo $PR_URL | grep -oP '\d+$')
80+
gh pr merge $PR_NUMBER --auto --merge
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)