enarx-archive / bot

I'm a bot. Bleep. Blorp.
2 stars 4 forks source link

Write a one-off action to remove issues from archived repos from boards #15

Closed mbestavros closed 4 years ago

mbestavros commented 4 years ago

Done. Here's the code I used:

#!/usr/bin/python3
# SPDX-License-Identifier: Apache-2.0

from github import Github

github = Github("token")
org = github.get_organization('enarx')

sprint = {p.name: p for p in org.get_projects(state='open')}['Sprint']
sprint_columns = {c.name: c for c in sprint.get_columns()}
planning = {p.name: p for p in org.get_projects(state='open')}['Planning']
planning_columns = {c.name: c for c in planning.get_columns()}

for card in sprint_columns['Assigned'].get_cards():
    # All archived issues on the board take the form of "notes" without an
    # associated issue (strangely). So, if there's no content for that card,
    # delete it from the board.
    if card.get_content() is None:
        card.delete()

for card in planning_columns['Triage'].get_cards():
    # All archived issues on the board take the form of "notes" without an
    # associated issue (strangely). So, if there's no content for that card,
    # delete it from the board.
    if card.get_content() is None:
        card.delete()