forked from dbt-msft/dbt-sqlserver
-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (36 loc) · 1.21 KB
/
Copy pathsync-master.yml
File metadata and controls
40 lines (36 loc) · 1.21 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
35
36
37
38
39
40
---
name: Sync default branches
on: # yamllint disable-line rule:truthy
schedule:
- cron: '0 0 * * 1' # weekly on Monday
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/sync-master.yml'
jobs:
sync-branches:
runs-on: ubuntu-latest
permissions:
contents: write
if: github.repository == 'dbt-msft/dbt-sqlserver'
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
ref: master
token: ${{ secrets.GITHUB_TOKEN }}
- name: Sync main to master
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -B main origin/main 2>/dev/null || git checkout -b main
if git merge --ff-only origin/master; then
echo "HAS_CHANGES=true" >> "$GITHUB_ENV"
else
echo "HAS_CHANGES=false" >> "$GITHUB_ENV"
fi
- name: Push main
if: env.HAS_CHANGES == 'true' && github.event_name != 'pull_request'
run: git push origin main
# After default branch is switched to main, swap the logic above:
# - checkout main, sync master <- main, push master