-
Notifications
You must be signed in to change notification settings - Fork 1
/
change_status.ts
47 lines (40 loc) · 1.46 KB
/
change_status.ts
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
import * as core from '@actions/core'
import axios from 'axios'
const run = async (): Promise<void> => {
try {
let failed : boolean = false;
const token = core.getInput('clickup_token')
const task_ids = core.getMultilineInput('clickup_custom_task_ids')
const team_id = core.getInput('clickup_team_id')
const target_status = core.getInput('clickup_status')
const body = {
"status": target_status
}
for (const task_id of task_ids) {
let endpoint = `https://api.clickup.com/api/v2/task/${task_id}/?custom_task_ids=true&team_id=${team_id}`
await axios.put(endpoint, body, {
headers: {
'Content-Type': 'application/json',
'Authorization': token
}
}).then(
(result) => {
let new_status = result.data.status.status
core.info(`Changed the status of ${task_id} to ${new_status} successfully.`)
}
).catch(
function (error) {
failed = true
core.info(`${task_id} error: ${error.message}`)
}
)
}
if (failed) {
throw 'One of the API requests has failed. Please check the logs for more details.'
}
} catch (error) {
core.setFailed(`Action failed: ${error}`)
}
}
run()
export default run