From 3cfc494cb72e26db28a705cdff2db0e5fa565c07 Mon Sep 17 00:00:00 2001 From: Javier Bullrich Date: Tue, 7 May 2024 19:57:46 +0200 Subject: [PATCH 1/4] removed unused test --- .github/workflows/example.yml | 39 ---------------- .github/workflows/review-trigger.yml | 68 ---------------------------- 2 files changed, 107 deletions(-) delete mode 100644 .github/workflows/example.yml delete mode 100644 .github/workflows/review-trigger.yml diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml deleted file mode 100644 index 4a82417..0000000 --- a/.github/workflows/example.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Example -on: - workflow_run: - workflows: - - Review-Trigger - types: - - completed - -jobs: - review-approvals: - runs-on: ubuntu-latest - steps: - - name: Publish payload - run: echo "$PAYLOAD" - env: - PAYLOAD: ${{toJson(github.event.workflow_run)}} - - name: Publish PR NUMBER - run: echo "$NUMBER" - env: - NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }} - - name: Extract content of artifact - id: number - uses: Bullrich/extract-text-from-artifact@v1.0.1 - with: - artifact-name: pr_number - - name: Generate token - id: app_token - uses: actions/create-github-app-token@v1.9.3 - with: - app-id: ${{ secrets.REVIEW_APP_ID }} - private-key: ${{ secrets.REVIEW_APP_KEY }} - - name: "Evaluates PR reviews and assigns reviewers" - uses: paritytech/review-bot@v2.4.0 - with: - repo-token: ${{ steps.app_token.outputs.token }} - team-token: ${{ steps.app_token.outputs.token }} - checks-token: ${{ steps.app_token.outputs.token }} - pr-number: ${{ steps.number.outputs.content }} - request-reviewers: true diff --git a/.github/workflows/review-trigger.yml b/.github/workflows/review-trigger.yml deleted file mode 100644 index 176eb49..0000000 --- a/.github/workflows/review-trigger.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: Review-Trigger - -on: - pull_request_target: - types: - - opened - - reopened - - synchronize - - review_requested - - review_request_removed - - ready_for_review - pull_request_review: - -jobs: - trigger-review-bot: - # (It is not a draft) && (it is not a review || it is an approving review) - if: ${{ github.event.pull_request.draft != true && (github.event_name != 'pull_request_review' || (github.event.review && github.event.review.state == 'APPROVED')) }} - runs-on: ubuntu-latest - name: trigger review bot - steps: - - name: Skip merge queue - if: ${{ contains(github.ref, 'gh-readonly-queue') }} - run: exit 0 - - name: Get comments - id: comments - run: echo "bodies=$(gh pr view ${{ github.event.number }} --repo ${{ github.repository }} --json comments --jq '[.comments[].body]')" >> "$GITHUB_OUTPUT" - env: - GH_TOKEN: ${{ github.token }} - - name: Fail when author pushes new code - # Require new reviews when the author is pushing and he is not a member - if: | - github.event_name == 'pull_request_target' && - github.event.action == 'synchronize' && - github.event.sender.login == github.event.pull_request.user.login && - github.event.pull_request.author_association != 'MEMBER' - run: | - # We get the list of reviewers who approved the PR - REVIEWERS=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.number }}/reviews \ - --jq '{reviewers: [.[] | select(.state == "APPROVED") | .user.login]}') - - # We request them to review again - echo $REVIEWERS | gh api --method POST repos/${{ github.repository }}/pulls/${{ github.event.number }}/requested_reviewers --input - - - echo "::error::Project needs to be reviewed again" - exit 1 - env: - GH_TOKEN: ${{ github.token }} - - name: Comment requirements - # If the previous step failed and github-actions hasn't commented yet we comment instructions - if: failure() && !contains(fromJson(steps.comments.outputs.bodies), 'Review required!') - run: | - gh pr comment ${{ github.event.number }} --repo ${{ github.repository }} --body "Review required! Latest push from author must always be reviewed" - env: - GH_TOKEN: ${{ github.token }} - COMMENTS: ${{ steps.comments.outputs.users }} - - name: Get PR number - env: - PR_NUMBER: ${{ github.event.pull_request.number }} - run: | - echo "Saving PR number: $PR_NUMBER" - mkdir -p ./pr - echo $PR_NUMBER > ./pr/pr_number - - uses: actions/upload-artifact@v3 - name: Save PR number - with: - name: pr_number - path: pr/ - retention-days: 5 From 062f297ca54ca4355595d38ab69890443a206f7a Mon Sep 17 00:00:00 2001 From: Javier Bullrich Date: Wed, 8 May 2024 00:29:44 +0200 Subject: [PATCH 2/4] added step to push changes in branch --- .github/workflows/cmd-check.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/cmd-check.yml b/.github/workflows/cmd-check.yml index cdc394f..52e72fc 100644 --- a/.github/workflows/cmd-check.yml +++ b/.github/workflows/cmd-check.yml @@ -31,3 +31,12 @@ jobs: with: branch: ${{ needs.cmd-check.outputs.branch }} command: ${{ matrix.command }} + - name: Check changes + run: | + git config --system user.name command-bot + git config --system user.email "github@users.noreply.github.com" + git add . + git commit -m "cmd-action - changes" + git push origin $BRANCH + env: + BRANCH: ${{ needs.cmd-check.outputs.branch }} From bdd150d13bc32b1ad594d000481ddb9a04109af0 Mon Sep 17 00:00:00 2001 From: Javier Bullrich Date: Wed, 8 May 2024 00:34:54 +0200 Subject: [PATCH 3/4] replaced push action --- .github/workflows/cmd-check.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cmd-check.yml b/.github/workflows/cmd-check.yml index 52e72fc..fac8948 100644 --- a/.github/workflows/cmd-check.yml +++ b/.github/workflows/cmd-check.yml @@ -31,12 +31,7 @@ jobs: with: branch: ${{ needs.cmd-check.outputs.branch }} command: ${{ matrix.command }} - - name: Check changes - run: | - git config --system user.name command-bot - git config --system user.email "github@users.noreply.github.com" - git add . - git commit -m "cmd-action - changes" - git push origin $BRANCH - env: - BRANCH: ${{ needs.cmd-check.outputs.branch }} + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: cmd-action - changes + branch: ${{ needs.cmd-check.outputs.branch }} From b286442b4a88f889c0d14fa469476a25f6fbf189 Mon Sep 17 00:00:00 2001 From: Javier Bullrich Date: Wed, 8 May 2024 15:24:43 +0200 Subject: [PATCH 4/4] updated to error message --- .github/workflows/cmd-check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmd-check.yml b/.github/workflows/cmd-check.yml index fac8948..2d6510d 100644 --- a/.github/workflows/cmd-check.yml +++ b/.github/workflows/cmd-check.yml @@ -27,10 +27,11 @@ jobs: command: ${{ fromJson(needs.cmd-check.outputs.commands) }} name: Run command steps: - - uses: paritytech/cmd-action/run@parse-comment + - uses: paritytech/cmd-action/run@error/report-with-comment with: branch: ${{ needs.cmd-check.outputs.branch }} command: ${{ matrix.command }} + pr-number: ${{ github.event.issue.number || github.event.pull_request.number }} - uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: cmd-action - changes