Files
containers/.github/workflows/delete-solved-cards.yml
Fran Mulero bd9843ac29 [bitnami/containers] Revisit workflow permissions (#36685)
* [bitnami/containers] Revisit workflow permissions

Signed-off-by: Fran Mulero <fmulero@vmware.com>

* Apply suggestions

Signed-off-by: Fran Mulero <fmulero@vmware.com>

---------

Signed-off-by: Fran Mulero <fmulero@vmware.com>
2023-06-07 12:49:47 +02:00

43 lines
1.2 KiB
YAML

name: '[Support] Delete Solved cards'
on:
workflow_dispatch:
schedule:
# Every 2 hours
- cron: '15 0/2 * * *'
# Remove all permissions by default
permissions: {}
jobs:
delete-cards:
runs-on: ubuntu-latest
permissions:
repository-projects: write
contents: read
steps:
- name: Repo checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Load .env file
uses: xom9ikk/dotenv@v2
with:
path: .github/workflows/
- uses: actions/github-script@v6
with:
script: |
const {data: cards} = await github.rest.projects.listCards({
column_id: ${{ env.SOLVED_COLUMN_ID }},
archived_state: 'all',
per_page: 100
});
// Remove cards without updates in last week.
const comparedDate = new Date();
comparedDate.setDate(comparedDate.getDate() - 7);
cards.forEach(card => {
const lastUpdate = new Date(card.updated_at);
if (card.archived || lastUpdate < comparedDate ) {
github.rest.projects.deleteCard({
card_id: card.id
});
}
});