ci: update global workflows (#547)

This commit is contained in:
LizardByte-bot 2022-12-12 20:04:06 -05:00 committed by GitHub
parent 6f369398b3
commit c60ebb76b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 9 deletions

View File

@ -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 }}

View File

@ -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