-
Notifications
You must be signed in to change notification settings - Fork 2
52 lines (44 loc) · 1.5 KB
/
sync-branches.yml
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
41
42
43
44
45
46
47
48
49
50
51
52
name: Sync branches
on:
push:
branches: [main]
jobs:
sync-branches:
timeout-minutes: 5
permissions:
contents: write
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
name: Sync branches
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GHA_APP_ID }}
private-key: ${{ secrets.GHA_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Get GitHub App user ID
if: ${{ github.event_name == 'push' }}
id: get-user-id
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Update values for git user config
if: ${{ github.event_name == 'push' }}
run: |
echo "GIT_USER_NAME=${{ steps.app-token.outputs.app-slug }}[bot]" >> $GITHUB_ENV
echo "GIT_USER_EMAIL=${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com" >> $GITHUB_ENV
- name: Merge main to dev
run: |
git config --local user.email "$GIT_USER_EMAIL"
git config --local user.name "$GIT_USER_NAME"
git checkout dev
git merge --ff --no-edit main
git push origin dev