[bitnami/containers] Fix workflow issues with existing cards (#21189)

Signed-off-by: Fran Mulero <fmulero@vmware.com>
This commit is contained in:
Fran Mulero 2023-01-20 11:29:54 +01:00 committed by GitHub
parent 4a8c33fffd
commit 44a80ecb4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 7 deletions

View File

@ -1,4 +1,4 @@
name: '[Support] Organizing cards based on comments'
name: '[Support] Comments based card movements'
on:
issue_comment:
types:
@ -7,6 +7,9 @@ permissions:
repository-projects: write
issues: write
pull-requests: write
# Avoid concurrency over the same issue
concurrency:
group: card-movement-${{ github.event.issue.number }}
jobs:
comments_handler:
runs-on: ubuntu-latest

View File

@ -0,0 +1,39 @@
name: '[Support] Delete Solved cards'
on:
workflow_dispatch:
schedule:
# Every 2 hours
- cron: '15 0/2 * * *'
permissions:
repository-projects: write
jobs:
delete-cards:
runs-on: ubuntu-latest
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
});
}
});

View File

@ -6,14 +6,30 @@ on:
pull_request_target:
types:
- closed
permissions:
repository-projects: write
# Avoid concurrency over the same issue
concurrency:
group: card-movement-${{ github.event_name != 'issues' && github.event.number || github.event.issue.number }}
jobs:
send_to_solved:
runs-on: ubuntu-latest
steps:
- name: Send to the Solved column
id: send-solved
uses: peter-evans/create-or-update-project-card@v2
with:
project-name: Support
column-name: 'Solved'
token: "${{ secrets.BITNAMI_BOT_TOKEN }}"
issue-number: ${{ github.event_name != 'issues' && github.event.number || github.event.issue.number }}
issue-number: ${{ github.event_name != 'issues' && github.event.number || github.event.issue.number }}
- name: Remove cards from automated PRs
if: |
(github.event.issue != null && github.event.issue.user.login == 'bitnami-bot') ||
(github.event.issue == null && github.event.pull_request.user.login == 'bitnami-bot')
uses: actions/github-script@v6
with:
script: |
github.rest.projects.deleteCard({
card_id: ${{ steps.send-solved.outputs.card-id }}
});

View File

@ -6,8 +6,10 @@ on:
- synchronize
permissions:
repository-projects: write
concurrency:
group: card-movement-${{ github.event.number }}
jobs:
comments_handler:
handler:
runs-on: ubuntu-latest
# This job will ignore:
# * Events triggered by bitnami-bot (README commits for example).
@ -15,11 +17,11 @@ jobs:
# * PRs with 'bitnami' label.
if: |
github.actor != 'bitnami-bot' && github.event.pull_request.user.login != 'bitnami-bot' &&
(!contains(github.event.pull_request.labels.*.name, 'bitnami'))
(!contains(github.event.pull_request.labels.*.name, 'bitnami')) && (!contains(github.event.pull_request.labels.*.name, 'triage'))
steps:
- name: Move into In Progress
uses: peter-evans/create-or-update-project-card@v2
with:
project-name: Support
column-name: In progress
issue-number: ${{ github.event.pull_request.number }}
issue-number: ${{ github.event.number }}

View File

@ -9,6 +9,9 @@ on:
types:
- reopened
- opened
# Avoid concurrency over the same issue
concurrency:
group: card-movement-${{ github.event_name != 'issues' && github.event.number || github.event.issue.number }}
jobs:
# For any opened or reopened issue, should be sent into Triage
send_to_board:
@ -27,12 +30,14 @@ jobs:
id: get-issue
run: |
author="${{ github.event.issue != null && github.event.issue.user.login || github.event.pull_request.user.login }}"
number="${{ github.event_name != 'issues' && github.event.number || github.event.issue.number }}"
echo "author=${author}" >> $GITHUB_OUTPUT
echo "number=${number}" >> $GITHUB_OUTPUT
- name: Send to the board
uses: peter-evans/create-or-update-project-card@v2
with:
project-name: Support
# If the author comes from Bitnami, send it to Bitnami. Otherwise, all to Triage
column-name: ${{ (!contains(fromJson(env.BITNAMI_TEAM), steps.get-issue.outputs.author)) && 'Triage' || 'From Bitnami' }}
column-name: ${{ (contains(fromJson(env.BITNAMI_TEAM), steps.get-issue.outputs.author)) && 'From Bitnami' || 'Triage' }}
token: "${{ secrets.BITNAMI_BOT_TOKEN }}"
issue-number: ${{ github.event_name != 'issues' && github.event.number || github.event.issue.number }}
issue-number: ${{ steps.get-issue.outputs.number }}