-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
96 lines (89 loc) · 3.35 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
90
91
92
93
94
95
# Milestone Action
# @author: hustcer
# @created: 2024/10/13 18:50:20
# Notice:
# Remember to change settings of the repository and update the Workflow permissions to
# allow "Read and write permissions"
# Disable actions and enable it again to make it work. Don't forget to save the changes.
# REF:
# - https://github.com/cli/cli
# - https://cli.github.com/manual/
# - https://github.com/actions/runner-images
# - https://github.com/orgs/community/discussions/60820
# - https://docs.github.com/cn/actions/creating-actions/about-custom-actions
# - https://docs.github.com/cn/actions/creating-actions/metadata-syntax-for-github-actions
# - https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
# - https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context
# - https://docs.github.com/en/actions/sharing-automations/creating-actions/creating-a-composite-action
name: 'Milestone Action'
author: 'hustcer'
description: 'A Github action to create, close, delete milestones and set milestone to merged PRs or closed issues 🔥'
branding:
icon: 'award'
color: 'purple'
inputs:
action:
required: false
default: 'bind-pr'
description: 'The action to perform, should be bind-pr,bind-issue,create, delete or close. Defaults to bind-pr.'
title:
required: false
default: '1.0.0'
description: 'The title of the milestone to create.'
description:
required: false
default: 'The first milestone.'
description: 'The description of the milestone to create.'
due-on:
required: false
default: ''
description: 'The due date of the milestone to create.'
force:
required: false
default: false
description: 'If the PR was already assigned to a milestone, force to set a new milestone. Defaults to false.'
milestone:
required: false
default: ''
description: 'The milestone to set, close or delete.'
github-token:
required: false
default: '${{ github.token }}'
description: 'The GITHUB_TOKEN secret or personal access token to authenticate. Defaults to `github.token`.'
outputs:
milestone-number:
value: ${{ steps.action.outputs.milestone-number }}
description: 'The number of the milestone created or closed.'
runs:
using: 'composite'
steps:
- name: Setup Nu
uses: hustcer/setup-nu@v3
with:
version: '0.101.0'
enable-plugins: nu_plugin_query
- name: Set Milestone
shell: nu {0}
id: action
run: |
use ${{ github.action_path }}/nu/milestone.nu *
let action = '${{ inputs.action }}'
let repo = '${{ github.repository }}'
let title = '${{ inputs.title }}'
let dueOn = '${{ inputs.due-on }}'
let description = '${{ inputs.description }}'
let token = '${{ inputs.github-token }}'
let milestone = '${{ inputs.milestone }}'
let issue = '${{ github.event.issue.number }}'
let pr = '${{ github.event.pull_request.number }}'
let force = '${{ inputs.force }}' | into bool
(milestone-action $action $repo
--pr=$pr
--issue=$issue
--force=$force
--gh-token=$token
--milestone=$milestone
--title=$title
--due-on=$dueOn
--description=$description
)