From 85126191f0bfbe4ea98a0719d77ac837c91a3a5f Mon Sep 17 00:00:00 2001 From: bitnami-bot Date: Tue, 19 Dec 2023 08:34:44 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=84=20synced=20local=20'.github/workfl?= =?UTF-8?q?ows/'=20with=20remote=20'workflows/'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: bitnami-bot --- .github/workflows/move-closed-issues.yml | 2 +- .github/workflows/pr-review-hack.yml | 58 ++++++++++++++++++++++++ .github/workflows/pr-reviews.yml | 24 +++++----- 3 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/pr-review-hack.yml diff --git a/.github/workflows/move-closed-issues.yml b/.github/workflows/move-closed-issues.yml index d9c7425..7abde6b 100644 --- a/.github/workflows/move-closed-issues.yml +++ b/.github/workflows/move-closed-issues.yml @@ -14,7 +14,7 @@ permissions: pull-requests: write # Avoid concurrency over the same issue concurrency: - group: card-movement-${{ github.event.repository.id }}-${{ github.event.issue != null && github.event.issue.number || github.event.number }} + group: card-movement-${{ github.event.issue != null && github.event.issue.number || github.event.number }} jobs: call-move-closed-workflow: uses: bitnami/support/.github/workflows/item-closed.yml@main diff --git a/.github/workflows/pr-review-hack.yml b/.github/workflows/pr-review-hack.yml new file mode 100644 index 0000000..6bc6638 --- /dev/null +++ b/.github/workflows/pr-review-hack.yml @@ -0,0 +1,58 @@ +# Copyright VMware, Inc. +# SPDX-License-Identifier: APACHE-2.0 + +# This is a hack to run reusable workflows in the main repo context and not from the forked repository. +# We this hack we can use secrets configured in the organization. +name: '[Support] PR review comment trigger' +on: + workflow_run: + workflows: + - '\[Support\] PR review comment card movements' + types: + - completed +permissions: {} +jobs: + pr-info: + runs-on: ubuntu-latest + permissions: + pull-requests: read + actions: read + outputs: + author: ${{ steps.get-info.outputs.author }} + actor: ${{ steps.get-info.outputs.actor }} + labels: ${{ steps.get-info.outputs.labels }} + resource_url: ${{ steps.get-info.outputs.resource_url }} + if: {{ github.event.workflow_run.conclusion == 'success' }} + steps: + - id: get-info + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + run: | + actor="${{ github.event.workflow_run.actor.login }}" + download_url="$(gh api "${{ github.event.workflow_run.artifacts_url }}" | jq -cr '.artifacts[] | select(.name == "pull_request_number") | .archive_download_url')" + curl -sSL -o pull_request_number.zip -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" -H "Authorization: Bearer $GITHUB_TOKEN" $download_url + unzip pull_request_number.zip + pull_request_number=$(cat pull_request_number) + pull_request="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${pull_request_number}")" + author="$(echo $pull_request | jq -cr '.user.login')" + author_association="$(echo $pull_request | jq -cr '.author_association')" + labels="$(echo $pull_request | jq -cr '[.labels[].name]')" + resource_url="$(echo $pull_request | jq -cr '.html_url')" + + echo "::notice:: Managing PR #${pull_request_number}" + echo "actor=${actor}" >> $GITHUB_OUTPUT + echo "author=${author}" >> $GITHUB_OUTPUT + echo "author_association=${author_association}" >> $GITHUB_OUTPUT + echo "labels=${labels}" >> $GITHUB_OUTPUT + echo "resource_url=${resource_url}" >> $GITHUB_OUTPUT + call-pr-review-comment: + uses: bitnami/support/.github/workflows/pr-review-comment.yml@main + needs: pr-info + permissions: + contents: read + secrets: inherit + with: + author: ${{ needs.pr-info.outputs.author }} + actor: ${{ needs.pr-info.outputs.actor }} + labels: ${{ needs.pr-info.outputs.labels }} + resource_url: ${{ needs.pr-info.outputs.resource_url }} diff --git a/.github/workflows/pr-reviews.yml b/.github/workflows/pr-reviews.yml index 07882f1..46d1ca4 100644 --- a/.github/workflows/pr-reviews.yml +++ b/.github/workflows/pr-reviews.yml @@ -6,20 +6,20 @@ on: pull_request_review_comment: types: - created - pull_request_review: - types: - - submitted - - dismissed permissions: {} # Avoid concurrency over the same issue concurrency: group: card-movement-${{ github.event.pull_request.number }} jobs: - call-pr-review-comment-workflow: - if: ${{ github.event_name == 'pull_request_review_comment' }} - uses: bitnami/support/.github/workflows/pr-review-comment.yml@main - secrets: inherit - call-pr-review-workflow: - if: ${{ github.event_name == 'pull_request_review' }} - uses: bitnami/support/.github/workflows/pr-review.yml@main - secrets: inherit \ No newline at end of file + just-notice: + # This is a dummy workflow that triggers a workflow_run + runs-on: ubuntu-latest + steps: + - run: | + echo "::notice:: Comment on PR #${{ github.event.pull_request.number }}" + echo "${{ github.event.pull_request.number }}" > pull_request_number + - name: Upload the PR number + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 + with: + name: pull_request_number + path: ./pull_request_number \ No newline at end of file