-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (59 loc) · 2.38 KB
/
sourcery_code_review.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Perform a code review on a pull request using the Sourcery Coding Assistant.
name: Sourcery Coding Assistant Review
on:
# Trigger the review on pull request events.
pull_request:
types:
# Trigger the review when either of these events occur:
#
# - a pull request is opened in non-draft state
# - a pull request is moved from draft to ready for review
# - the "sourcery-review" label is added to the pull request: add this label
# to your pull request to trigger a review. To re-request reviews, remove the
# label and add it again.
#
# Feel free to edit this list to suit your team's needs. See the list of all
# activity types here:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
- opened
- ready_for_review
- labeled
permissions:
# Read the contents of the repository
contents: read
# Create a pull request review
pull-requests: write
jobs:
sourcery-coding-assistant-review:
# Only run this job when a PR is opened in non draft state,
# is moved from draft to ready for review,
# or the "sourcery-review" label is added to the pull request.
if: |
github.event.action == 'opened' && !github.event.pull_request.draft ||
github.event.action == 'ready_for_review' ||
github.event.label.name == 'sourcery-review'
runs-on: ubuntu-latest
steps:
- name: Install Sourcery
shell: bash
# Install the latest nightly version of Sourcery from PyPI.
# This gives you access to the latest features and bug fixes.
# To install the latest stable version, use `pip install sourcery`.
run: |
pip install --pre sourcery-nightly
- name: Log into Sourcery
shell: bash
# Log into Sourcery using the Sourcery token stored in the SOURCERY_TOKEN GitHub
# secret.
run: |
sourcery login \
--token ${{ secrets.SOURCERY_TOKEN }}
- name: Run Sourcery code review
# Run the Sourcery code review on the pull request that triggered this workflow.
shell: bash
run: |
sourcery assistant review pull-request \
--token ${{ github.token }} \
--repository ${{ github.repository }} \
--pull-request ${{ github.event.pull_request.number }} \
--commit ${{ github.event.pull_request.head.sha }}