Skip to content

Commit

Permalink
GitHub workflow: Migrate MilestoneIssue to shared action (#6370)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-mikula-sonarsource authored Nov 18, 2022
1 parent 9b87b41 commit 638c7a6
Showing 1 changed file with 3 additions and 33 deletions.
36 changes: 3 additions & 33 deletions .github/workflows/MilestoneIssue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 638c7a6

Please sign in to comment.