-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
50 lines (46 loc) · 1.48 KB
/
action.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
name: "Sync Upstream"
description: "Synchronize a branch from an upstream repository to a target repository"
color: "blue"
icon: "git-merge"
inputs:
github_token:
description: "GitHub token for authentication"
required: true
target_repository:
description: "Target repository in the format owner/repo"
required: true
target_branch:
description: "Branch in the target repository to sync"
required: true
upstream_repository:
description: "Upstream repository in the format owner/repo"
required: true
upstream_branch:
description: "Branch in the upstream repository to sync"
required: true
runs:
using: "composite"
steps:
- name: Checkout target branch
uses: actions/checkout@v4
with:
token: ${{ inputs.github_token }}
repository: ${{ inputs.target_repository }}
- name: Add upstream repository
run: |
git remote add upstream https://github.com/${{ inputs.upstream_repository }}.git
git fetch upstream ${{ inputs.upstream_branch }}
shell: bash
- name: Sync target branch with upstream
run: |
git checkout -B ${{ inputs.target_branch }}
git reset --hard upstream/${{ inputs.upstream_branch }}
shell: bash
- name: Sync tags with upstream
run: |
git fetch upstream --tags
git push origin --tags --force
shell: bash
- name: Push synchronized branch
run: git push origin ${{ inputs.target_branch }} --force
shell: bash