🤖 Dependabot outstanding PR's and issues #1454
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: Add issue to epic | |
on: # yamllint disable-line rule:truthy | |
issues: | |
types: | |
- labeled | |
concurrency: | |
group: add-issue-to-epic | |
cancel-in-progress: false | |
permissions: read-all | |
jobs: | |
add-issue-to-epic: | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
steps: | |
- name: Add issue to Epic | |
id: add_issue_to_epic | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
console.log("Starting script..."); | |
const payload = context.payload; | |
const issueNumber = payload.issue.number; | |
const issueTitle = payload.issue.title; | |
const labelName = payload.label.name; | |
console.log(`Issue Number: ${issueNumber}`); | |
console.log(`Issue Title: ${issueTitle}`); | |
console.log(`Label Name: ${labelName}`); | |
// Check if the label applied is an Epic label | |
if (!labelName.includes('(Epic #')) { | |
console.log('The applied label is not an Epic label. Exiting...'); | |
return; | |
} | |
// Extract the Epic's issue number from the label name | |
const epicNumber = labelName.match(/\(Epic #(\d+)\)/)[1]; | |
console.log(`Epic Number Extracted: ${epicNumber}`); | |
if (!epicNumber) { | |
console.log('Could not determine the Epic issue number. Exiting...'); | |
return; | |
} | |
// Fetch the description of the Epic | |
const epic = await github.rest.issues.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: epicNumber | |
}); | |
const epicBody = epic.data.body; | |
console.log("Fetched Epic Body:"); | |
console.log(epicBody); | |
// Amend the Epic description with a checkbox and link to the new issue | |
const newItemLink = `- [ ] #${issueNumber}`; | |
console.log(`New Item Link: ${newItemLink}`); | |
const updatedDescription = `${epicBody}\n${newItemLink}`; | |
console.log("Updated Description:"); | |
console.log(updatedDescription); | |
// Update the Epic description | |
await github.rest.issues.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: epicNumber, | |
body: updatedDescription | |
}); | |
console.log("Epic description updated successfully."); |