forked from opendatahub-io/kubeflow
-
Notifications
You must be signed in to change notification settings - Fork 4
47 lines (40 loc) · 1.63 KB
/
sync-branches-through-pr.yaml
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
---
name: Sync branches through Pull Request
on: # yamllint disable-line rule:truthy
workflow_dispatch:
inputs:
source:
description: Source branch
required: true
target:
description: Target branch
required: true
jobs:
sync:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.target }}
fetch-depth: 0
- name: Prepare sync branch
id: prepare
run: |
git fetch origin ${{ github.event.inputs.source }}
git reset --hard origin/${{ github.event.inputs.source }}
TIMESTAMP=$(date +'%Y%m%d%H%M%S')
SYNC_BRANCH=sync__${{ github.event.inputs.source }}__${{ github.event.inputs.target }}__${TIMESTAMP}
echo "branch=$SYNC_BRANCH" >> $GITHUB_OUTPUT
- name: Create pull request
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
branch: ${{ steps.prepare.outputs.branch }}
title: "Sync `${{ github.event.inputs.target }}` branch with `${{ github.event.inputs.source }}` branch"
body: |
:robot: This is an automated Pull Request created by `/.github/workflows/sync-branches-through-pr.yml`.
It merges all commits from `${{ github.event.inputs.source }}` branch into `${{ github.event.inputs.target }}` branch.
:warning: **IMPORTANT NOTE**: Remember to delete the `${{ steps.prepare.outputs.branch }}` branch after merging the changes.