-
Notifications
You must be signed in to change notification settings - Fork 2.2k
73 lines (71 loc) · 2.97 KB
/
merge-develop-into-flake-demo.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Merge develop into flake-demo
on:
push:
branches:
- develop
jobs:
merge-master-into-develop:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set committer info
run: |
git config --local user.email "$(git log --format='%ae' HEAD^!)"
git config --local user.name "$(git log --format='%an' HEAD^!)"
- name: Checkout flake-demo branch
run: git checkout flake-demo
- name: Check for merge conflict
id: check-conflict
run: echo "name=merge_conflict::$(git merge-tree $(git merge-base HEAD develop) develop HEAD | egrep '<<<<<<<')" >> $GITHUB_OUTPUT
- name: Merge develop into flake-demo
run: git merge develop
if: ${{ !steps.check-conflict.outputs.merge_conflict }}
- name: Push
run: git push
if: ${{ !steps.check-conflict.outputs.merge_conflict }}
- name: Checkout develop
run: git checkout develop
if: ${{ steps.check-conflict.outputs.merge_conflict }}
- name: Determine name of new branch
id: gen-names
run: |
echo "name=sha::$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "name=branch_name::$(git rev-parse --short HEAD)-develop-into-flake-demo" >> $GITHUB_OUTPUT
if: ${{ steps.check-conflict.outputs.merge_conflict }}
- name: Create a copy of develop on a new branch
run: git checkout -b ${{ steps.gen-names.outputs.branch_name }} develop
if: ${{ steps.check-conflict.outputs.merge_conflict }}
- name: Push branch to remote
run: git push origin ${{ steps.gen-names.outputs.branch_name }}
if: ${{ steps.check-conflict.outputs.merge_conflict }}
- name: Create Pull Request
uses: actions/github-script@v7
with:
script: |
const pull = await github.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
base: 'flake-demo',
head: '${{ steps.gen-names.outputs.branch_name }}',
title: 'chore: merge develop (${{ steps.gen-names.outputs.sha }}) into flake-demo',
body: `There was a merge conflict when trying to automatically merge develop into flake-demo. Please resolve the conflict and complete the merge.
DO NOT SQUASH AND MERGE
@${context.actor}`,
maintainer_can_modify: true,
})
await github.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull.data.number,
reviewers: [context.actor],
})
await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pull.data.number,
labels: ['auto-merge'],
})
if: ${{ steps.check-conflict.outputs.merge_conflict }}