-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub workflow: Migrate MilestoneIssue to shared action (#6370)
- Loading branch information
1 parent
9b87b41
commit 638c7a6
Showing
1 changed file
with
3 additions
and
33 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,44 +5,14 @@ on: | |
types: ["milestoned"] | ||
|
||
jobs: | ||
create_card: | ||
CreateCardForMilestonedIssue_job: | ||
name: Create card | ||
runs-on: ubuntu-latest | ||
# Single quotes must be used here https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#literals | ||
if: github.event.issue.state != 'closed' | ||
|
||
steps: | ||
# https://github.com/actions/github-script | ||
- uses: actions/[email protected] | ||
- uses: sonarsource/gh-action-lt-backlog/CreateCardForIssue@v1 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const TODO_COLUMN = 4971951; | ||
const IN_PROGRESS_COLUMN = 4971952; | ||
const REVIEW_IN_PROGRESS_COLUMN = 4971953; | ||
const REVIEW_APPROVED_COLUMN = 4971954; | ||
const VALIDATE_PEACH_COLUMN = 7838551; | ||
const DONE_COLUMN = 4971955; | ||
// | ||
async function findCard(content_url) { | ||
// Columns are searched from the most probable one | ||
const allColumns = [TODO_COLUMN, IN_PROGRESS_COLUMN, REVIEW_IN_PROGRESS_COLUMN, REVIEW_APPROVED_COLUMN, VALIDATE_PEACH_COLUMN, DONE_COLUMN]; | ||
for (let i = 0; i < allColumns.length; i++) { | ||
let cards = await github.projects.listCards({ column_id: allColumns[i] }); | ||
let card = cards.data.find(x => x.content_url == content_url); | ||
if (card) { | ||
return card; | ||
} | ||
} | ||
console.log("Card not found for: " + content_url); | ||
return null; | ||
} | ||
// | ||
const card = await findCard(context.payload.issue.url); | ||
if (card) { | ||
console.log("Card already exists"); | ||
} else { | ||
console.log("Creating Issue card"); | ||
github.projects.createCard({ column_id: TODO_COLUMN, content_id: context.payload.issue.id, content_type: "Issue" }); | ||
} | ||
console.log("Done"); | ||
column-id: 4971951 # Kanban "To do" column |