Skip to content

Commit

Permalink
debug(labels.yml): wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed Aug 10, 2024
1 parent 86b7d7e commit 035437b
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
paths:
- ".github/workflows/labels.yml"
workflow_dispatch:

jobs:
create-labels:
Expand Down Expand Up @@ -41,26 +42,11 @@ jobs:
{"name": "timeout:4hrs", "color": "5319E7", "description": "Duration in hours after which the instance will be stopped"}
]
steps:
- uses: actions/github-script@v7
with:
script: |
const labels = JSON.parse(process.env.LABELS_JSON);
for (const label of labels) {
try {
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: label.name,
description: label.description || '',
color: label.color
});
} catch (error) {
// Check if the error is because the label already exists
if (error.status === 422) {
console.log(`Label '${label.name}' already exists. Skipping.`);
} else {
// Log other errors
console.error(`Error creating label '${label.name}': ${error}`);
}
}
}
- name: Create or Update Labels
run: |
echo $LABELS_JSON | jq -r '.[] | [.name, .color, .description] | @tsv' | \
while IFS=$'\t' read -r name color description; do
echo "name [${name}]"
echo "color [${color}]"
echo "description [${description}]"
done

0 comments on commit 035437b

Please sign in to comment.