generated from cloudposse-github-actions/composite-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
54 lines (52 loc) · 1.59 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
name: 'Preview environment controller labels cleanup'
description: 'Remove deploy PR labels'
author: [email protected]
branding:
icon: 'delete'
color: 'white'
inputs:
labels_env:
description: "JSON formatted {label}: {environment} map "
required: true
default: "{}"
env:
description: Environment
required: true
pr_number:
description: The number of the pull request, which will default to extracting from the workflow event if not specified.
required: false
outputs: {}
runs:
using: "composite"
steps:
- uses: cloudposse/[email protected]
id: label
with:
compact: true
raw-output: true
input: ${{ inputs.labels_env }}
script: ${{ format('.{0}', inputs.env) }}
- uses: actions/github-script@v7
with:
script: |
const label = '${{ steps.label.outputs.output }}';
const prNumber = '${{ inputs.pr_number }}';
if (label) {
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
name: label
});
console.log(`Successfully removed label: ${label}`);
} catch (error) {
// Ignore 404 errors (label doesn't exist)
if (error.status !== 404) {
throw error;
}
console.log(`Label ${label} was not found on PR #${prNumber}`);
}
} else {
console.log('No label to remove');
}