Files
containers/.github/workflows/delete-solved-cards.yml
dependabot[bot] 23418dca87 Bump actions/github-script from 6.4.1 to 7.0.1 (#53017)
Bumps [actions/github-script](https://github.com/actions/github-script) from 6.4.1 to 7.0.1.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](d7906e4ad0...60a0d83039)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-20 09:24:23 +01:00

47 lines
1.4 KiB
YAML

# Copyright VMware, Inc.
# SPDX-License-Identifier: APACHE-2.0
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@b4ffde65f46336ab88eb53be808477a3936bae11
with:
fetch-depth: 1
- name: Load .env file
uses: xom9ikk/dotenv@de1ff27d319507880e6621e4d47424c677d95f68
with:
path: .github/workflows/
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
script: |
const {SOLVED_COLUMN_ID} = process.env
const {data: cards} = await github.rest.projects.listCards({
column_id: `${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
});
}
});