Skip to content

Remediate Trivy Alerts on Cluster Resources #769

Remediate Trivy Alerts on Cluster Resources

Remediate Trivy Alerts on Cluster Resources #769

name: Create Epic Label
on:
issues:
types: [labeled]
# Ensure the workflow runs only once at a time
concurrency:
group: create-epic-label
cancel-in-progress: true
jobs:
create_epic_label:
runs-on: ubuntu-latest
if: github.event.label.name == 'Epic'
steps:
- name: Check if Epic and Create Label
uses: actions/github-script@v7.0.1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issueTitle = context.payload.issue.title;
const issueNumber = context.payload.issue.number;
const labelName = `${issueTitle} (Epic #${issueNumber})`;
const labels = context.payload.issue.labels;
// Generate a random 6-digit hexadecimal color
const randomColor = Math.floor(Math.random()*16777215).toString(16);
// Check if label already exists
const existingLabels = await github.paginate(github.rest.issues.listLabelsForRepo, {
owner: context.repo.owner,
repo: context.repo.repo
});
if (!existingLabels.find(label => label.name === labelName)) {
// Label doesn't exist, create it
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: labelName,
color: randomColor
});
}