📖 Airflow 3.0 - Initial Infrastructure Buildout for Airflow-Dev #1464
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Create epic label | |
on: # yamllint disable-line rule:truthy | |
issues: | |
types: | |
- labeled | |
concurrency: | |
group: create-epic-label | |
cancel-in-progress: true | |
permissions: read-all | |
jobs: | |
create-epic-label: | |
if: github.event.label.name == 'Epic' | |
name: Create epic label | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
steps: | |
- name: Create epic label | |
id: create_epic_label | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # 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 | |
}); | |
} |