-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
action.yml
54 lines (54 loc) · 2.07 KB
/
action.yml
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
name: 'add-linear-author-as-reviewer'
description: 'Add Linear author as reviewer'
author: 'Mergify'
branding:
icon: 'at-sign'
color: 'blue'
inputs:
LINEAR_API_KEY:
required: true
description: 'Linear Api Key'
GITHUB_TOKEN:
required: true
description: 'GitHub Token'
EMAIL_MAPPING:
required: true
description: 'Linear Email to GitHub login mapping (one by line and separated by a space)'
LINEAR_ISSUE_REGEX:
required: false
description: 'Linear issue regex to find the issue ID'
default: 'MRGFY-\d+'
runs:
using: 'composite'
steps:
- id: extract
shell: bash
run: |
python3 -m venv venv
venv/bin/pip install -r ${{ github.action_path }}/requirements.txt
venv/bin/python ${{ github.action_path }}/linear-extract-reviewers.py >> $GITHUB_OUTPUT
env:
INPUT_LINEAR_API_KEY: ${{ inputs.LINEAR_API_KEY }}
INPUT_LINEAR_ISSUE_REGEX: ${{ inputs.LINEAR_ISSUE_REGEX }}
INPUT_EMAIL_MAPPING: ${{ inputs.EMAIL_MAPPING }}
INPUT_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }}
- shell: bash
if: "${{ steps.extract.outputs.creators }}"
run: |
set -x
for creator in ${{steps.extract.outputs.creators}}; do
gh pr view ${{github.event.pull_request.html_url}} --json latestReviews |jq -e '.latestReviews[] | select(.author.login == "'${creator}'" and .state != "DISMISSED" and .state != "COMMENTED")' \
&& \
echo "Review of ${creator} has already been requested" \
|| \
curl -X POST \
-H "Content-type: application/json" \
-H "Accept: application/json" \
-H "Authorization: token $GITHUB_TOKEN" \
-d '{"reviewers": ["'${creator}'"]}' \
${{github.event.pull_request.url}}/requested_reviewers
# This doesn't work because of https://github.com/cli/cli/issues/4844
# gh pr edit ${{github.event.pull_request.html_url}} --add-reviewer $creator
done
env:
GITHUB_TOKEN: ${{inputs.GITHUB_TOKEN}}