File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ name : Sync branches through Pull Request
3+
4+ on : # yamllint disable-line rule:truthy
5+ workflow_dispatch :
6+ inputs :
7+ source :
8+ description : Source branch
9+ required : true
10+ target :
11+ description : Target branch
12+ required : true
13+
14+ jobs :
15+ sync :
16+ permissions :
17+ contents : write
18+ pull-requests : write
19+ runs-on : ubuntu-latest
20+ steps :
21+ - name : Checkout repository
22+ uses : actions/checkout@v4
23+ with :
24+ ref : ${{ github.event.inputs.target }}
25+ fetch-depth : 0
26+
27+ - name : Prepare sync branch
28+ id : prepare
29+ run : |
30+ git fetch origin ${{ github.event.inputs.source }}
31+ git reset --hard origin/${{ github.event.inputs.source }}
32+
33+ TIMESTAMP=$(date +'%Y%m%d%H%M%S')
34+ SYNC_BRANCH=sync__${{ github.event.inputs.source }}__${{ github.event.inputs.target }}__${TIMESTAMP}
35+ echo "branch=$SYNC_BRANCH" >> $GITHUB_OUTPUT
36+
37+ - name : Create pull request
38+ uses : peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
39+ with :
40+ branch : ${{ steps.prepare.outputs.branch }}
41+ title : " Sync `${{ github.event.inputs.target }}` branch with `${{ github.event.inputs.source }}` branch"
42+ body : |
43+ :robot: This is an automated Pull Request created by `/.github/workflows/sync-branches-through-pr.yml`.
44+
45+ It merges all commits from `${{ github.event.inputs.source }}` branch into `${{ github.event.inputs.target }}` branch.
46+
47+ :warning: **IMPORTANT NOTE**: Remember to delete the `${{ steps.prepare.outputs.branch }}` branch after merging the changes.
You can’t perform that action at this time.
0 commit comments