From 0248b4b93ff79b236625b831708de1c0f6bcecde Mon Sep 17 00:00:00 2001 From: Fran Mulero Date: Thu, 22 Sep 2022 15:53:19 +0200 Subject: [PATCH] [bitnami/*] Split workflow responsibilites (#12622) * [bitnami/*] Split workflow responsibilities Signed-off-by: Fran Mulero * [bitnami/*] Split workflow responsibilities Signed-off-by: Fran Mulero * Build Maintenance colummn configured Signed-off-by: Fran Mulero * Amend README badge Signed-off-by: Fran Mulero * Set BITNAMI_BOT_TOKEN to trigger comment action Signed-off-by: Fran Mulero Signed-off-by: Fran Mulero --- .github/workflows/.env | 2 + .../{cd-pipeline.yaml => cd-pipeline.yml} | 0 ...redis.yaml => ci-pipeline-extra-redis.yml} | 0 ...anos.yaml => ci-pipeline-extra-thanos.yml} | 0 .../{ci-pipeline.yaml => ci-pipeline.yml} | 42 +------ .github/workflows/comments.yml | 47 ++++---- .github/workflows/move-closed-issues.yml | 30 +---- .github/workflows/moving-cards.yml | 111 ++++++++++++++---- .github/workflows/stale.yml | 4 +- .github/workflows/triage.yml | 37 ++---- README.md | 2 +- 11 files changed, 132 insertions(+), 143 deletions(-) rename .github/workflows/{cd-pipeline.yaml => cd-pipeline.yml} (100%) rename .github/workflows/{ci-pipeline-extra-redis.yaml => ci-pipeline-extra-redis.yml} (100%) rename .github/workflows/{ci-pipeline-extra-thanos.yaml => ci-pipeline-extra-thanos.yml} (100%) rename .github/workflows/{ci-pipeline.yaml => ci-pipeline.yml} (85%) diff --git a/.github/workflows/.env b/.github/workflows/.env index 84bb49f00..599fc2655 100644 --- a/.github/workflows/.env +++ b/.github/workflows/.env @@ -5,5 +5,7 @@ SOLVED_COLUMN_ID=19057379 ON_HOLD_COLUMN_ID=19057378 BITNAMI_COLUMN_ID=19057375 PENDING_COLUMN_ID=19057377 +BUILD_MAINTENANCE_COLUMN_ID=19174507 SUPPORT_TEAM_NAME='charts-support' TRIAGE_TEAM_NAME='charts-triage' +BUILD_MAINTAINERS_TEAM_NAME='build-maintainers' \ No newline at end of file diff --git a/.github/workflows/cd-pipeline.yaml b/.github/workflows/cd-pipeline.yml similarity index 100% rename from .github/workflows/cd-pipeline.yaml rename to .github/workflows/cd-pipeline.yml diff --git a/.github/workflows/ci-pipeline-extra-redis.yaml b/.github/workflows/ci-pipeline-extra-redis.yml similarity index 100% rename from .github/workflows/ci-pipeline-extra-redis.yaml rename to .github/workflows/ci-pipeline-extra-redis.yml diff --git a/.github/workflows/ci-pipeline-extra-thanos.yaml b/.github/workflows/ci-pipeline-extra-thanos.yml similarity index 100% rename from .github/workflows/ci-pipeline-extra-thanos.yaml rename to .github/workflows/ci-pipeline-extra-thanos.yml diff --git a/.github/workflows/ci-pipeline.yaml b/.github/workflows/ci-pipeline.yml similarity index 85% rename from .github/workflows/ci-pipeline.yaml rename to .github/workflows/ci-pipeline.yml index f1d7b538b..e54fa4447 100644 --- a/.github/workflows/ci-pipeline.yaml +++ b/.github/workflows/ci-pipeline.yml @@ -14,20 +14,6 @@ env: CSP_API_TOKEN: ${{ secrets.CSP_API_TOKEN }} VIB_PUBLIC_URL: https://cp.bromelia.vmware.com jobs: - auto-pr-triage: - runs-on: ubuntu-latest - name: Triage for automated PRs - if: | - contains(github.event.pull_request.title, 'Release') && - github.event.action == 'opened' && - github.actor == 'bitnami-bot' - steps: - # Adds 'verify' label to indicate the VIB Verify job can be executed - - name: Label PR to be verified - uses: andymckay/labeler@1.0.4 - with: - repo-token: '${{ secrets.GITHUB_TOKEN }}' - add-labels: 'verify' get-chart: runs-on: ubuntu-latest name: Get modified charts @@ -135,21 +121,17 @@ jobs: # not taking into account whether 'VIB Verify' succeeded if: | always() && - needs.auto-pr-triage.result == 'success' + contains(github.event.pull_request.labels.*.name, 'auto-merge') && + github.event.pull_request.user.login == 'bitnami-bot' steps: - name: Enable auto-merge feature if: ${{ needs.vib-verify.result == 'success' }} uses: reitermarkus/automerge@v2.1.2 with: + # Necessary to trigger CD workflow token: ${{ secrets.BITNAMI_BOT_TOKEN }} merge-method: squash pull-request: ${{ github.event.number }} - - name: Label PR as auto-merge - if: ${{ needs.vib-verify.result == 'success' }} - uses: andymckay/labeler@1.0.4 - with: - repo-token: '${{ secrets.GITHUB_TOKEN }}' - add-labels: 'auto-merge' # Approve the CI's PR if the 'VIB Verify' job succeeded # Approved by the 'github-actions' user; a PR can't be approved by its author - name: PR approval @@ -157,7 +139,6 @@ jobs: uses: hmarr/auto-approve-action@v2.4.0 with: pull-request-number: ${{ github.event.number }} - # If the CI did not succeed ('VIB Verify' failed or skipped), # post a comment on the PR and assign a maintainer agent to review it - name: Manual review required @@ -165,21 +146,8 @@ jobs: uses: peter-evans/create-or-update-comment@v2.0.0 with: issue-number: ${{ github.event.number }} + # Necessary to trigger support workflows + token: ${{ secrets.BITNAMI_BOT_TOKEN }} body: | There has been an error during the automated release process. Manual revision is now required. Please check the related [action_run#${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more information. - - name: Assign PR to a maintaner agent - if: ${{ needs.vib-verify.result != 'success' }} - uses: pozil/auto-assign-issue@v1.9.0 - with: - numOfAssignee: 1 - teams: build-maintainers - repo-token: '${{ secrets.BITNAMI_BOT_TOKEN }}' - - name: Move into From Bitnami - uses: peter-evans/create-or-update-project-card@v2.0.0 - if: ${{ needs.vib-verify.result != 'success' }} - with: - project-name: Support - column-name: From Bitnami - token: '${{ secrets.GITHUB_TOKEN }}' - issue-number: ${{ github.event.number }} diff --git a/.github/workflows/comments.yml b/.github/workflows/comments.yml index dba5b5801..8b994e2e5 100644 --- a/.github/workflows/comments.yml +++ b/.github/workflows/comments.yml @@ -4,18 +4,11 @@ on: types: - created permissions: + repository-projects: write issues: write pull-requests: write - repository-projects: write - -# To fix the concurrency when for example more than one label is added -concurrency: - group: ${{ github.run_id }} - cancel-in-progress: false - jobs: comments_handler: - if: ${{ github.actor != 'bitnami-bot' && ((github.event.pull_request && (!contains(github.event.pull_request.labels.*.name, 'auto-merge'))) || (github.event.issue && (!contains(github.event.issue.labels.*.name, 'auto-merge')))) }} runs-on: ubuntu-latest steps: - name: Repo checkout @@ -26,36 +19,38 @@ jobs: uses: xom9ikk/dotenv@v1.0.2 with: path: .github/workflows/ + - name: Move into From Build Maintenance + uses: peter-evans/create-or-update-project-card@v2 + # The comment was created by bitnami-bot in a pull_request + if: ${{ github.actor == 'bitnami-bot' && github.event.issue.pull_request != null }} + with: + project-name: Support + column-name: Build Maintenance + # Required to trigger moving-cards.yml workflow (clean labels and assign people to work on it) + token: "${{ secrets.BITNAMI_BOT_TOKEN }}" - name: Move into Pending uses: peter-evans/create-or-update-project-card@v2 - if: ${{ (!contains(github.event.issue.labels.*.name, 'bitnami')) && contains(fromJson(env.BITNAMI_TEAM), github.event.comment.user.login) }} + if: | + (github.actor != 'bitnami-bot' || github.event.issue.pull_request == null) && + (!contains(github.event.issue.labels.*.name, 'bitnami')) && contains(fromJson(env.BITNAMI_TEAM), github.actor) with: project-name: Support column-name: Pending - token: "${{ secrets.GITHUB_TOKEN }}" - name: Move into In Progress uses: peter-evans/create-or-update-project-card@v2 - if: ${{ contains(github.event.issue.labels.*.name, 'in-progress') && (!contains(fromJson(env.BITNAMI_TEAM), github.event.comment.user.login)) }} + if: | + (github.actor != 'bitnami-bot' || github.event.issue.pull_request == null) && + contains(github.event.issue.labels.*.name, 'in-progress') && (!contains(fromJson(env.BITNAMI_TEAM), github.actor)) with: project-name: Support column-name: In progress - token: "${{ secrets.GITHUB_TOKEN }}" - name: Move into Triage uses: peter-evans/create-or-update-project-card@v2 - if: ${{ ((contains(github.event.issue.labels.*.name, 'triage')) || (contains(github.event.issue.labels.*.name, 'solved'))) && (!contains(fromJson(env.BITNAMI_TEAM), github.event.comment.user.login)) }} + if: | + (github.actor != 'bitnami-bot' || github.event.issue.pull_request == null) && + ((contains(github.event.issue.labels.*.name, 'triage')) || (contains(github.event.issue.labels.*.name, 'solved'))) && (!contains(fromJson(env.BITNAMI_TEAM), github.actor)) with: project-name: Support column-name: Triage - token: "${{ secrets.GITHUB_TOKEN }}" - - name: Label as triage back - # Only if commented when solved - if: ${{ contains(github.event.issue.labels.*.name, 'solved') }} - uses: andymckay/labeler@1.0.4 - with: - add-labels: "triage" - remove-labels: "solved" - - name: Removing the stale label - if: ${{ contains(github.event.issue.labels.*.name, 'stale') }} - uses: andymckay/labeler@1.0.4 - with: - remove-labels: "stale" \ No newline at end of file + # Needs reasignation of the task + token: "${{ secrets.BITNAMI_BOT_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/move-closed-issues.yml b/.github/workflows/move-closed-issues.yml index 45b39ae5d..15dc12b11 100644 --- a/.github/workflows/move-closed-issues.yml +++ b/.github/workflows/move-closed-issues.yml @@ -6,40 +6,14 @@ on: pull_request_target: types: - closed - -permissions: - issues: write - pull-requests: write - repository-projects: write - -# To fix the concurrency when for example more than one label is added -concurrency: - group: ${{ github.run_id }} - cancel-in-progress: false - jobs: send_to_solved: - if: ${{ github.actor != 'bitnami-bot' || (github.actor == 'bitnami-bot' && github.event.issue && (!contains(github.event.issue.labels.*.name, 'stale'))) }} runs-on: ubuntu-latest steps: - - name: Repo checkout - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - name: Load .env file - uses: xom9ikk/dotenv@v1.0.2 - with: - path: .github/workflows/ - name: Send to the Solved column 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: 'Solved' - issue-number: ${{ github.event_name != 'issues' && github.event.number || github.event.issue.number }} - - name: Solved labeling - # Only if moved into Solved - uses: andymckay/labeler@1.0.4 - with: - add-labels: "solved" - remove-labels: "in-progress, on-hold, triage" + token: "${{ secrets.BITNAMI_BOT_TOKEN }}" + issue-number: ${{ github.event_name != 'issues' && github.event.number || github.event.issue.number }} \ No newline at end of file diff --git a/.github/workflows/moving-cards.yml b/.github/workflows/moving-cards.yml index ae8e303dd..43e974f21 100644 --- a/.github/workflows/moving-cards.yml +++ b/.github/workflows/moving-cards.yml @@ -3,22 +3,41 @@ name: '[Support] Cards movements' on: project_card: types: + - created - moved - permissions: issues: write pull-requests: write - repository-projects: read - -# To fix the concurrency when for example more than one label is added -concurrency: - group: ${{ github.run_id }} - cancel-in-progress: false - jobs: - label-card: - if: ${{ github.actor != 'bitnami-bot' }} + get-issue: runs-on: ubuntu-latest + name: Get issue info + outputs: + assignees: ${{ steps.get-issue-step.outputs.assignees }} + author: ${{ steps.get-issue-step.outputs.author }} + type: ${{ steps.get-issue-step.outputs.type }} + draft: ${{ steps.get-issue-step.outputs.draft }} + steps: + - name: Get issue info + id: get-issue-step + run: | + issue_info=$(curl -s --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -X GET -G "${{ github.event.project_card.content_url }}" ) + assignees="$(echo $issue_info | jq -r '.assignees')" + author="$(echo $issue_info | jq -r '.user.login')" + pull_request="$(echo $issue_info | jq -r '.pull_request')" + draft="$(echo $issue_info | jq -r '.draft' | sed -r "s|null|false|g")" + type="pull_request" + if [[ "${pull_request}" == "null" ]]; then + type="issue" + fi + echo "::set-output name=assignees::${assignees}" + echo "::set-output name=author::${author}" + echo "::set-output name=type::${type}" + echo "::set-output name=draft::${draft}" + label-card: + runs-on: ubuntu-latest + needs: + - get-issue steps: - name: Repo checkout uses: actions/checkout@v3 @@ -29,30 +48,67 @@ jobs: with: path: .github/workflows/ # Now handling the needed labeling + - name: Triage labeling + # Only if moved into triage + if: ${{ github.event.project_card.column_id == env.TRIAGE_COLUMN_ID }} + uses: andymckay/labeler@1.0.4 + with: + add-labels: triage + remove-labels: on-hold, in-progress, solved + - name: From Bitnami labeling + if: ${{ github.event.project_card.column_id == env.BITNAMI_COLUMN_ID }} + uses: andymckay/labeler@1.0.4 + with: + add-labels: ${{ (needs.get-issue.outputs.author == 'bitnami-bot' && needs.get-issue.outputs.type == 'pull_request') && 'automated, auto-merge' || 'bitnami' }} + remove-labels: on-hold, in-progress, triage, solved + - name: Verify labeling + # Only if moved into bitnami column and the PR is ready for review + if: | + github.event.project_card.column_id == env.BITNAMI_COLUMN_ID && + needs.get-issue.outputs.type == 'pull_request' && needs.get-issue.outputs.draft == 'false' + uses: andymckay/labeler@1.0.4 + with: + add-labels: verify + # Required to trigger CI workflow + repo-token: ${{ secrets.BITNAMI_BOT_TOKEN }} + - name: Build Maintenance labeling + if: ${{ github.event.project_card.column_id == env.BUILD_MAINTENANCE_COLUMN_ID }} + uses: andymckay/labeler@1.0.4 + with: + add-labels: review-required + remove-labels: auto-merge - name: On hold labeling # Only if moved into on hold if: ${{ github.event.project_card.column_id == env.ON_HOLD_COLUMN_ID }} uses: andymckay/labeler@1.0.4 with: - add-labels: "on-hold" - remove-labels: "triage" + add-labels: on-hold + remove-labels: triage, in-progress, solved - name: In progress labeling # Only if moved into In progress if: ${{ github.event.project_card.column_id == env.IN_PROGRESS_COLUMN_ID }} uses: andymckay/labeler@1.0.4 with: - add-labels: "in-progress" - remove-labels: "on-hold, triage" + add-labels: in-progress + remove-labels: on-hold, triage, solved - name: Solved labeling - # Only if moved into Solved - if: ${{ github.event.project_card.column_id == env.SOLVED_COLUMN_ID }} + # Only if moved into Solved and the issue author is not bitnami-bot + if: | + github.event.project_card.column_id == env.SOLVED_COLUMN_ID && + (needs.get-issue.outputs.author != 'bitnami-bot') uses: andymckay/labeler@1.0.4 with: - add-labels: "solved" - remove-labels: "in-progress, on-hold, triage" + add-labels: solved + # Triage is not on the list to know how many issues/PRs are solved + # directly on triage + remove-labels: in-progress, on-hold assign-assignee-if-needed: - if: ${{ github.actor != 'bitnami-bot' && (!contains(github.event.issue.labels.*.name, 'auto-merge')) }} runs-on: ubuntu-latest + needs: + - get-issue + # The job shouldn't run for solved cards or new PRs created by bitnami-bot + if: | + (github.event.action != 'created' || needs.get-issue.outputs.type != 'pull_request' || needs.get-issue.outputs.author != 'bitnami-bot') steps: - name: Repo checkout uses: actions/checkout@v3 @@ -63,11 +119,22 @@ jobs: with: path: .github/workflows/ - name: Assign to a person to work on it - # Only if moved into In progress FROM Triage - if: ${{ github.event.project_card.column_id == env.IN_PROGRESS_COLUMN_ID && github.event.changes != null && github.event.changes.column_id && github.event.changes.column_id.from == env.TRIAGE_COLUMN_ID }} + # Assign when there is nobody assigned or the card is new + if: ${{ github.event.project_card.column_id != env.SOLVED_COLUMN_ID && (needs.get-issue.outputs.assignees == '[]' || github.event.action == 'created') }} + uses: pozil/auto-assign-issue@v1.9.0 + with: + numOfAssignee: 1 + teams: ${{ github.event.project_card.column_id == env.BITNAMI_COLUMN_ID && env.SUPPORT_TEAM_NAME || (github.event.project_card.column_id == env.BUILD_MAINTENANCE_COLUMN_ID && env.BUILD_MAINTAINERS_TEAM_NAME || env.TRIAGE_TEAM_NAME) }} + repo-token: ${{ secrets.BITNAMI_BOT_TOKEN }} + - name: Reassign when moved into 'In progress' from 'Triage' + # Reassigned when moved into In progress FROM Triage + if: | + github.event.action == 'moved' && needs.get-issue.outputs.assignees != '[]' && + github.event.project_card.column_id == env.IN_PROGRESS_COLUMN_ID && + github.event.changes.column_id.from == env.TRIAGE_COLUMN_ID uses: pozil/auto-assign-issue@v1.9.0 with: numOfAssignee: 1 removePreviousAssignees: true teams: ${{ env.SUPPORT_TEAM_NAME }} - repo-token: "${{ secrets.BITNAMI_BOT_TOKEN }}" \ No newline at end of file + repo-token: ${{ secrets.BITNAMI_BOT_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index ed630bf0a..5e5756631 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -2,7 +2,9 @@ name: '[Support] Close stale issues and PRs' on: schedule: - cron: '0 1 * * *' - +permissions: + issues: write + pull-requests: write jobs: stale: runs-on: ubuntu-latest diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index e3725df88..e0ea5f56e 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -9,20 +9,9 @@ on: types: - reopened - opened -permissions: - issues: write - pull-requests: write - repository-projects: write - -# To fix the concurrency when for example more than one label is added -concurrency: - group: ${{ github.run_id }} - cancel-in-progress: false - jobs: # For any opened or reopened issue, should be sent into Triage send_to_board: - if: ${{ github.actor != 'bitnami-bot' }} runs-on: ubuntu-latest steps: - name: Repo checkout @@ -33,26 +22,18 @@ jobs: uses: xom9ikk/dotenv@v1.0.2 with: path: .github/workflows/ - - name: Assign to a person to work on it - uses: pozil/auto-assign-issue@v1.9.0 - with: - numOfAssignee: 1 - removePreviousAssignees: false - # If it's an internal issue, assign directly to the support team. Otherwise, to the triage one. - teams: ${{ (contains(fromJson(env.BITNAMI_TEAM), github.actor)) && env.SUPPORT_TEAM_NAME || env.TRIAGE_TEAM_NAME }} - repo-token: "${{ secrets.BITNAMI_BOT_TOKEN }}" + - name: Get author + 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 "::set-output name=author::${author}" + echo "::set-output name=number::${number}" - 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), github.actor)) && 'From Bitnami' || 'Triage' }} + 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 }} - - name: Triage labeling - # Only if moved into Solved - uses: andymckay/labeler@1.0.4 - with: - add-labels: ${{ (!contains(fromJson(env.BITNAMI_TEAM), github.actor)) && 'triage' || 'bitnami' }} - # For reopened issues - remove-labels: "solved" \ No newline at end of file + issue-number: ${{ steps.get-issue.outputs.number }} \ No newline at end of file diff --git a/README.md b/README.md index 90eaa46c8..1fdd60136 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/bitnami)](https://artifacthub.io/packages/search?repo=bitnami) -[![CD Pipeline](https://github.com/bitnami/charts/actions/workflows/cd-pipeline.yaml/badge.svg)](https://github.com/bitnami/charts/actions/workflows/cd-pipeline.yaml) +[![CD Pipeline](https://github.com/bitnami/charts/actions/workflows/cd-pipeline.yml/badge.svg)](https://github.com/bitnami/charts/actions/workflows/cd-pipeline.yml) # The Bitnami Library for Kubernetes