Skip to content

Commit f121949

Browse files
authored
Handle existing stack label in CI labelling job (#3413)
1 parent 2cb5f17 commit f121949

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

.github/filters.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ mgmt:
6464
- .github/**
6565
- .devcontainer/**
6666
- automations/**
67+
- utilities/**
6768
ci_cd:
6869
- .github/actions/**
6970
- .github/workflows/ci_cd.yml

.github/workflows/ci_cd.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,31 @@ jobs:
134134
# - list of stack filters: `.github/filters.yml`
135135
# - list of stack labels: https://github.com/WordPress/openverse/labels?q=stack
136136
script: |
137-
const stacks = ["catalog", "api", "ingestion_server", "frontend", "documentation", "mgmt"]
138-
const labels = JSON
139-
.parse('${{ needs.get-changes.outputs.changes }}')
140-
.filter(change => stacks.includes(change))
141-
.map(change => `🧱 stack: ${change.replace("_", " ")}`)
142-
if (!labels.length) {
143-
labels.push("🚦 status: awaiting triage", "🏷 status: label work required")
144-
}
145-
github.rest.issues.addLabels({
137+
const labels = await github.rest.issues.listLabelsOnIssue({
146138
issue_number: context.issue.number,
147139
owner: context.repo.owner,
148140
repo: context.repo.repo,
149-
labels,
150141
})
142+
console.log(labels.data)
143+
if (labels.data.some(label => label.name.startsWith("🧱 stack: "))) {
144+
console.log("Stack label already applied, skipping.")
145+
} else {
146+
const stacks = ["catalog", "api", "ingestion_server", "frontend", "documentation", "mgmt"]
147+
const labels = JSON
148+
.parse('${{ needs.get-changes.outputs.changes }}')
149+
.filter(change => stacks.includes(change))
150+
.map(change => `🧱 stack: ${change.replace("_", " ")}`)
151+
if (!labels.length) {
152+
console.log("Couldn't determine stack, applying triage labels.")
153+
labels.push("🚦 status: awaiting triage", "🏷 status: label work required")
154+
}
155+
await github.rest.issues.addLabels({
156+
issue_number: context.issue.number,
157+
owner: context.repo.owner,
158+
repo: context.repo.repo,
159+
labels,
160+
})
161+
}
151162
152163
build-images:
153164
name: Build Docker images

0 commit comments

Comments
 (0)