-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
47 lines (46 loc) · 1.49 KB
/
action.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
name: 'Close Pull'
description: 'A GitHub action to close a pull request and optionally delete its branch'
inputs:
token:
description: 'GITHUB_TOKEN or a repo scoped PAT'
default: ${{ github.token }}
repository:
description: 'The GitHub repository containing the pull request'
default: ${{ github.repository }}
pull-request-number:
description: 'The number of the pull request to close'
default: ${{ github.event.number }}
comment:
description: 'A comment to make on the pull request before closing'
delete-branch:
description: 'Delete the pull request branch'
default: false
runs:
using: composite
steps:
- name: Set Parameters
id: params
shell: bash
run: |
if [ -n "${{ inputs.comment }}" ]; then
comment="--comment \"${{ inputs.comment }}\""
delimiter="$(openssl rand -hex 8)"
echo "comment<<$delimiter" >> $GITHUB_OUTPUT
echo "$comment" >> $GITHUB_OUTPUT
echo "$delimiter" >> $GITHUB_OUTPUT
fi
if [ "${{ inputs.delete-branch }}" = true ]; then
echo delete-branch="--delete-branch" >> $GITHUB_OUTPUT
fi
- name: Close Pull
shell: bash
run: |
gh pr close -R "${{ inputs.repository }}" \
${{ steps.params.outputs.comment }} \
${{ steps.params.outputs.delete-branch }} \
"${{ inputs.pull-request-number }}"
env:
GH_TOKEN: ${{ inputs.token }}
branding:
icon: 'git-pull-request'
color: 'gray-dark'