|
9 | 9 | sync-demo-branch:
|
10 | 10 | runs-on: ubuntu-latest
|
11 | 11 | steps:
|
| 12 | + # Checkout the demo branch first, this is where we'll merge into |
12 | 13 | - name: Checkout demo branch
|
13 |
| - uses: actions/checkout@v3 |
| 14 | + uses: actions/checkout@v4 |
14 | 15 | with:
|
15 | 16 | ref: 'demo'
|
16 |
| - token: ${{ secrets.DEMO_UPDATE_PAT }} # Use the PAT for checkout |
| 17 | + token: ${{ secrets.DEMO_UPDATE_PAT }} |
| 18 | + fetch-depth: 0 # Needed for merge history |
17 | 19 |
|
18 |
| - - name: Fetch changes from main branch |
19 |
| - run: git fetch origin main |
20 |
| - |
21 |
| - - name: Checkout main branch files excluding .github, cypress-example, and playwright-example |
| 20 | + # Configure Git user for the commit |
| 21 | + - name: Configure Git User |
22 | 22 | run: |
|
23 |
| - git checkout origin/main -- . ':!/.github' ':!/cypress-example' ':!/playwright-example' |
| 23 | + # Using generic bot details, you can change these if desired |
| 24 | + git config user.name "GitHub Actions Bot" |
| 25 | + git config user.email "actions-bot@github.com" |
| 26 | +
|
| 27 | + # Fetch the latest changes from the remote, including main |
| 28 | + - name: Fetch origin |
| 29 | + run: git fetch origin |
24 | 30 |
|
25 |
| - - name: Find last merged branch |
26 |
| - id: last-merged-branch |
| 31 | + # Perform the merge from main into the currently checked out demo branch |
| 32 | + - name: Merge main into demo |
27 | 33 | run: |
|
28 |
| - git fetch --all |
29 |
| - last_branch=$(git log -1 --pretty=format:"%s" | awk -F 'from ' '{print $2}') |
30 |
| - echo "branch=$last_branch" >> $GITHUB_OUTPUT |
| 34 | + # Merge main. --no-ff creates a merge commit. |
| 35 | + # Git automatically uses .gitattributes in the demo branch. |
| 36 | + git merge --no-ff origin/main -m "Auto-merge main into demo" |
| 37 | + # This step might fail on complex conflicts not handled by merge=ours. |
31 | 38 |
|
32 |
| - - name: Commit and push changes to demo branch |
| 39 | + # Push the merge commit back to the demo branch |
| 40 | + - name: Push changes to demo |
33 | 41 | run: |
|
34 |
| - git config --global user.email "peter@petermsouzajr.com" |
35 |
| - git config --global user.name "Peter Souza" |
36 |
| - branch_name="${{ steps.last-merged-branch.outputs.branch }}" |
37 |
| - git commit -am "Sync changes from main branch to demo (merged from $branch_name)" || echo "No changes to commit" |
38 |
| - git push https://${{ secrets.DEMO_UPDATE_PAT }}@github.com/petermsouzajr/qa-shadow-report.git demo |
| 42 | + git push origin demo |
| 43 | + # actions/checkout@v4 with token handles auth for push |
0 commit comments