From c60ebb76b902eccd19c8005793bb87deccbfbd7b Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Mon, 12 Dec 2022 20:04:06 -0500 Subject: [PATCH] ci: update global workflows (#547) --- .github/workflows/autoupdate-labeler.yml | 41 ++++++++++++++++++++---- .github/workflows/autoupdate.yml | 9 ++++-- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/.github/workflows/autoupdate-labeler.yml b/.github/workflows/autoupdate-labeler.yml index c4da7339..92b00988 100644 --- a/.github/workflows/autoupdate-labeler.yml +++ b/.github/workflows/autoupdate-labeler.yml @@ -6,22 +6,46 @@ name: Label PR autoupdate on: - pull_request: + pull_request_target: types: - edited - opened + - synchronize + pull_request_review: + types: + - edited + - submitted jobs: label_pr: if: >- startsWith(github.repository, 'LizardByte/') && - contains(github.event.pull_request.body, fromJSON('"] I want maintainers to keep my branch updated\r"')) + contains(github.event.pull_request.body, fromJSON('"] I want maintainers to keep my branch updated"')) runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} steps: + - name: Check if member + id: org_member + run: | + status="true" + gh api \ + -H "Accept: application/vnd.github+json" \ + /orgs/${{ github.repository_owner }}/members/${{ github.actor }} || status="false" + + echo "result=${status}" >> $GITHUB_OUTPUT + - name: Label autoupdate if: >- + steps.org_member.outputs.result == 'true' && + contains(github.event.pull_request.labels.*.name, 'autoupdate') == false && contains(github.event.pull_request.body, - fromJSON('"\n- [x] I want maintainers to keep my branch updated\r"')) == true + fromJSON('"\n- [x] I want maintainers to keep my branch updated"')) == true && + ( + (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || + (github.event_name == 'pull_request') + ) + uses: actions/github-script@v6 with: github-token: ${{ secrets.GH_BOT_TOKEN }} @@ -35,9 +59,14 @@ jobs: - name: Unlabel autoupdate if: >- - contains(github.event.pull_request.body, - fromJSON('"\n- [x] I want maintainers to keep my branch updated\r"')) == false && - contains(github.event.pull_request.labels.*.name, 'autoupdate') + contains(github.event.pull_request.labels.*.name, 'autoupdate') && + github.event_name == 'pull_request' && + ( + (github.event.action == 'synchronize' && steps.org_member.outputs.result == 'false') || + (contains(github.event.pull_request.body, + fromJSON('"\n- [x] I want maintainers to keep my branch updated"')) == false + ) + ) uses: actions/github-script@v6 with: github-token: ${{ secrets.GH_BOT_TOKEN }} diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml index f9060629..4522182f 100644 --- a/.github/workflows/autoupdate.yml +++ b/.github/workflows/autoupdate.yml @@ -3,8 +3,9 @@ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in # the above-mentioned repo. -# This workflow is designed to work with: -# - automerge workflows +# This workflow is designed to work with the following workflows: +# - automerge +# - autoupdate-labeler # It uses GitHub Action that auto-updates pull requests branches, when changes are pushed to their destination branch. # Auto-updating to the latest destination branch works only in the context of upstream repo and not forks. @@ -34,7 +35,9 @@ jobs: dependabot-rebase: name: Dependabot Rebase - if: startsWith(github.repository, 'LizardByte/') + if: >- + startsWith(github.repository, 'LizardByte/') && + contains(github.event.pull_request.labels.*.name, 'central_dependency') == false runs-on: ubuntu-latest steps: - name: rebase