-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
66 lines (61 loc) · 2.03 KB
/
action.yml
File metadata and controls
66 lines (61 loc) · 2.03 KB
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
name: sync-branch-github-action
description: Sync branch with GitHub Actions.
author: remarkablemark
inputs:
base:
description: Base branch
required: true
head:
description: Head branch (e.g., master)
default: ${{ github.event.repository.default_branch }}
merge:
description: Merge method (merge, squash, rebase)
default: merge
title:
description: Pull request title
body:
description: Pull request body
delete-branch:
description: Delete the local and remote branch after merge
admin:
description: Use administrator privileges to merge a pull request that does not meet requirements
token:
description: GitHub token
default: ${{ github.token }}
runs:
using: composite
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Create pull request
id: pull_request
continue-on-error: true
shell: bash
run: |
PULL_REQUEST_URL=$(
gh pr create \
--base ${{ toJSON(inputs.base) }} \
--head ${{ toJSON(inputs.head) }} \
--title "$PULL_REQUEST_TITLE" \
--body "$PULL_REQUEST_BODY"
)
echo "PULL_REQUEST_URL=$PULL_REQUEST_URL" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ inputs.token }}
PULL_REQUEST_TITLE: >-
${{ inputs.title || format('chore(sync-branch): merge `{0}` to `{1}`', inputs.head, inputs.base) }}
PULL_REQUEST_BODY: >-
${{ inputs.body || format('🤖 [sync-branch](https://github.com/remarkablemark/sync-branch): merging `{0}` to `{1}`', inputs.head, inputs.base) }}
- name: Merge pull request
if: ${{ steps.pull_request.outputs.PULL_REQUEST_URL }}
shell: bash
run: >
gh pr merge ${{ steps.pull_request.outputs.PULL_REQUEST_URL }}
${{ format('--{0}', inputs.merge) }}
${{ inputs.admin == 'true' && '--admin' || '' }}
${{ inputs.delete-branch == 'true' && '--delete-branch' || '' }}
env:
GH_TOKEN: ${{ inputs.token }}
branding:
icon: git-merge
color: purple