-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (61 loc) · 2.53 KB
/
verify-pull-request.yml
File metadata and controls
64 lines (61 loc) · 2.53 KB
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
name: Verify Pull Request meets Requirements
on:
pull_request: # need write permission
branches:
- main
types: [opened, edited]
jobs:
mirror-linked-issue:
runs-on: ubuntu-latest # find-linked-issue GitHub Action is only supported on Linux
permissions:
contents: read
issues: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
sparse-checkout: |
.github
token: ${{ secrets.GITHUB_TOKEN }}
- id: add-issue-to-body
name: Link issue in body
run: | # get the title, take the first word which should be the issue number, and add this to the body
title="${{ github.event.pull_request.title }}"
issue_number=${title%% *}
new_body="Closes #$issue_number"$'\n\n'"${{ github.event.pull_request.body }}"
gh pr edit ${{ github.event.pull_request.number }} --body "$new_body"
echo "Edited the body to include the issue number $issue_number"
echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: copy-issue-labels
name: Copy Issue Labels
uses: michalvankodev/copy-issue-labels@v1.2.1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
from-title: true
- name: Get issue assignee
id: get-issue-assignee
run: |
first_assignee=$(gh issue view "${{ steps.add-issue-to-body.outputs.issue_number }}" \
--json assignees \
--jq '.assignees[0].login')
echo "first_assignee=$first_assignee" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set PR assignee
run: gh pr edit ${{ github.event.pull_request.number }} --add-assignee "${{ env.ISSUE_ASSIGNEE }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_ASSIGNEE: ${{ steps.get-issue-assignee.outputs.first_assignee }}
- name: Set PR reviewer to Declan
if: ${{ steps.get-issue-assignee.outputs.first_assignee == 'varunsingh87' }}
run: gh pr edit ${{ github.event.pull_request.number }} --add-reviewer "Datoneguy246"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set PR reviewer to Varun
if: ${{ steps.get-issue-assignee.outputs.first_assignee == 'Datoneguy246' }}
run: gh pr edit ${{ github.event.pull_request.number }} --add-reviewer "varunsingh87"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}