-
Notifications
You must be signed in to change notification settings - Fork 25
/
action.yml
151 lines (140 loc) · 6.41 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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: "project beta automations"
description: 'GitHub ProjectV2/Project-Beta automation. It supports management of status and custom fields.'
inputs:
gh_host:
description: 'The hostname will be used by gh-cli. This works for enterprise customers.'
required: false
default: "github.com"
gh_token:
description: 'Permission token that grants permission to the GitHub API. (Toke or App config is required)'
required: false
default: ""
gh_app_secret_key:
description: 'Github App secret RSA key used to sign App JWT tokens'
required: false
default: ""
gh_app_ID:
description: 'Github App ID used to authenticate againts the API'
required: false
default: ""
gh_app_installation_ID:
description: 'Github App installation ID used to retrive installation token'
required: false
default: ""
organization:
description: 'Organization the project is stored in'
required: false
default: ""
user:
description: 'User the project is stored in'
required: false
default: ""
project_id:
description: 'Project ID owned by the organization'
required: true
default: ""
resource_node_id:
description: 'Defines the global node ID of the GitHub issue or pull request'
required: true
default: ""
status_value:
description: 'Specifies the destination card to which the issue or pull request should be moved. The value must be of type string. Example: "Todo"'
required: false
default: ""
operation_mode:
description: |
Specifies the operation mode.
The value must be of type string.
The value can be one of the following:
- custom_field
- status
required: false
default: "status"
custom_field_values:
description: |
Specifies the custom field values to be set on the issue or pull request.
The value must be an array of objects.
Example: '[{\"name\": \"Priority\",\"type\": \"text\",\"value\": \"uuid1\"},{\"name\": \"Severity\",\"type\": \"text\",\"value\": \"uuid2\"},{\"name\": \"Number\",\"type\": \"number\",\"value\": \"100\"},{\"name\": \"Date\",\"type\": \"date\",\"value\": \"2022-01-28T20:02:27.306+01:00\"},{\"name\": \"Single Select\",\"type\": \"single_select\",\"value\": \"Option 1\"},{\"name\": \"Iteration\",\"type\": \"iteration\",\"value\": \"Iteration 1\"}]'
required: false
move_related_issues:
description: |
Specifies whether to move related issues.
The value must be of type boolean.
The value can be one of the following:
- true
- false
required: false
default: "false"
branding:
icon: 'terminal'
color: 'blue'
runs:
using: "composite"
steps:
- name: "Install the gh cli tool if not installed"
shell: bash
run: ${{ github.action_path }}/deps.sh
- name: "Error missing auth conf"
if: inputs.gh_app_secret_key == '' && inputs.gh_app_ID == '' && inputs.gh_token == ''
shell: bash
run: echo "No GH Auth method configured, provide PAT or App ID/Key"; exit 1
- name: "Authenticate gh cli Github App"
if: inputs.gh_app_secret_key != '' && inputs.gh_app_ID != '' && inputs.gh_app_installation_ID
shell: bash
run: "${{ github.action_path }}/gh_app_credential_helper.sh \"${{ inputs.gh_app_secret_key }}\" \"${{ inputs.gh_app_ID }}\" \"${{ inputs.gh_app_installation_ID }}\" | gh auth login --with-token --hostname \"${{ inputs.gh_host }}\""
- name: "Authenticate gh cli PAT"
if: inputs.gh_token != ''
shell: bash
run: echo "${{ inputs.gh_token }}" | gh auth login --with-token --hostname "${{ inputs.gh_host }}"
- name: "Check if User or Organization is set"
if: inputs.organization == '' && inputs.user == ''
uses: actions/github-script@v3
with:
script: |
core.setFailed('either user or organization is not specified.')
- name: "Check if User and Organization are set"
if: inputs.organization != '' && inputs.user != ''
uses: actions/github-script@v3
with:
script: |
core.setFailed('user and organization field is set. Only one is supported.')
- name: "Check if operation_mode is set and custom_field_values is not null"
if: inputs.operation_mode == 'custom_field' && inputs.custom_field_values == ''
uses: actions/github-script@v3
with:
script: |
core.setFailed('operation mode is set to custom_field but custom_field_values is not set.')
- name: Export MOVE_RELATED_ISSUES
if: inputs.move_related_issues != ''
shell: bash
run: echo "MOVE_RELATED_ISSUES=${{ inputs.move_related_issues }}" >> $GITHUB_ENV
# execute organization script
- name: Execute Status Organization automation
if: inputs.organization != '' && inputs.operation_mode == 'status'
working-directory: ${{ github.action_path }}
env:
GITHUB_TOKEN: ${{ inputs.gh_token }}
shell: bash
run: "${{ github.action_path }}/entrypoint.sh \"organization\" \"status\" \"${{ inputs.organization }}\" \"${{ inputs.project_id }}\" \"${{ inputs.resource_node_id }}\" \"${{ inputs.status_value }}\""
- name: Execute Custom Field Organization automation
if: inputs.organization != '' && inputs.operation_mode == 'custom_field'
working-directory: ${{ github.action_path }}
env:
GITHUB_TOKEN: ${{ inputs.gh_token }}
shell: bash
run: "${{ github.action_path }}/entrypoint.sh \"organization\" \"custom_field\" \"${{ inputs.organization }}\" \"${{ inputs.project_id }}\" \"${{ inputs.resource_node_id }}\" \"${{ inputs.custom_field_values }}\""
# execute user script
- name: Execute Status User automation
if: inputs.user != '' && inputs.operation_mode == 'status'
working-directory: ${{ github.action_path }}
env:
GITHUB_TOKEN: ${{ inputs.gh_token }}
shell: bash
run: "${{ github.action_path }}/entrypoint.sh \"user\" \"status\" \"${{ inputs.user }}\" \"${{ inputs.project_id }}\" \"${{ inputs.resource_node_id }}\" \"${{ inputs.status_value }}\""
- name: Execute Custom Field User automation
if: inputs.user != '' && inputs.operation_mode == 'custom_field'
working-directory: ${{ github.action_path }}
env:
GITHUB_TOKEN: ${{ inputs.gh_token }}
shell: bash
run: "${{ github.action_path }}/entrypoint.sh \"user\" \"custom_field\" \"${{ inputs.user }}\" \"${{ inputs.project_id }}\" \"${{ inputs.resource_node_id }}\" \"${{ inputs.custom_field_values }}\""