-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
89 lines (79 loc) · 3.11 KB
/
action.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: "Create sync PR"
description: "Create PR that syncs between two branches"
inputs:
repository:
description: "Repository (e.g., gisce/react-ooui)"
required: true
baseBranch:
description: "Base branch (e.g., main)"
required: true
targetBranch:
description: "Target branch (e.g., alpha)"
required: true
githubToken:
description: "GitHub token for authentication"
required: true
releaseType:
description: "Type of release (e.g., minor, major, patch)"
required: true
runs:
using: "composite"
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ inputs.targetBranch }}
- name: Configure Git
shell: bash
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Create sync branch and merge
shell: bash
run: |
git fetch origin
# Create sync branch from current position
sync_branch="sync/${{ inputs.baseBranch }}-to-${{ inputs.targetBranch }}-$(date +%Y%m%d-%H%M%S)"
echo "SYNC_BRANCH=$sync_branch" >> $GITHUB_ENV
# Try to merge, if conflicts occur resolve using base branch (theirs)
if ! git merge origin/${{ inputs.baseBranch }} --no-edit --no-verify --no-commit; then
git merge --abort
git merge origin/${{ inputs.baseBranch }} -X theirs --no-edit --no-verify --no-commit
echo "CONFLICTS=true" >> $GITHUB_ENV
fi
# Check if there are any changes to commit
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to sync - working tree clean"
exit 0
fi
- name: Determine Commit Message
id: commit-message
run: |
RELEASE_TYPE=${{ inputs.releaseType }}
if [[ "$RELEASE_TYPE" == "patch" ]]; then
PREFIX="fix"
elif [[ "$RELEASE_TYPE" == "minor" ]]; then
PREFIX="feat"
elif [[ "$RELEASE_TYPE" == "major" ]]; then
PREFIX="feat"
BREAKING_CHANGE="BREAKING CHANGE: bump major version"
echo "BREAKING_CHANGE=$BREAKING_CHANGE" >> $GITHUB_ENV
elif [[ "$RELEASE_TYPE" == "none" ]]; then
PREFIX="chore"
fi
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
shell: bash
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ inputs.githubToken }}
title: "${{ env.PREFIX }}: sync changes from ${{ inputs.baseBranch }} to ${{ inputs.targetBranch }}${{ env.CONFLICTS == 'true' && ' (🚨 CONFLICTS RESOLVED)' || '' }}"
body: |
This PR syncs changes from the ${{ inputs.baseBranch }} branch to ${{ inputs.targetBranch }}.
${{ env.CONFLICTS == 'true' && '# 🚨 **BE CAREFUL BEFORE MERGING**
There were conflicts that were automatically resolved using changes from base branch.' || '' }}
commit-message: |
${{ env.PREFIX }}: sync changes from ${{ inputs.baseBranch }} to ${{ inputs.targetBranch }}
${{ env.BREAKING_CHANGE }}
branch: ${{ env.SYNC_BRANCH }}