forked from dotnet/dotnet-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (81 loc) · 3.69 KB
/
submit-linter-suggestions.yml
File metadata and controls
92 lines (81 loc) · 3.69 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: 'Submit linter suggestions'
on:
workflow_run:
workflows: ["C# linting", "Add Markdown Feedback", "Check Learning Path Links"]
types:
- completed
permissions: {}
jobs:
submit-linter-suggestions:
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
name: 'Submit linter suggestions'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: 'Verify user is a collaborator'
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410
with:
script: |
await github.rest.repos.checkCollaborator({
owner: context.repo.owner,
repo: context.repo.repo,
username: context.payload.workflow_run.triggering_actor.login
});
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
with:
persist-credentials: false
- name: Set C# Linting Env Vars
if: ${{ github.event.workflow_run.name == 'C# Linting' }}
run: |
echo 'reporter_name=dotnet format' >> $GITHUB_ENV
echo 'workflow_name=lint-csharp.yml' >> $GITHUB_ENV
- name: Set Append Markdown Feedback Env Vars
if: ${{ github.event.workflow_run.name == 'Add Markdown Feedback' }}
run: |
echo 'reporter_name=Add Markdown Feedback' >> $GITHUB_ENV
echo 'workflow_name=add-markdown-feedback.yml' >> $GITHUB_ENV
- name: Set Learning Path File Checks Env Vars
if: ${{ github.event.workflow_run.name == 'Check Learning Path Links' }}
run: |
echo 'reporter_name=Learning Path File Checks' >> $GITHUB_ENV
echo 'workflow_name=check-learning-path-links.yml' >> $GITHUB_ENV
# Download the artifact from the workflow that kicked off this one.
# The default artifact download action doesn't support cross-workflow
# artifacts, so use a 3rd party one.
- name: 'Download linting results'
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e
with:
workflow: ${{env.workflow_name}}
run_id: ${{github.event.workflow_run.id }}
name: pr-linter
path: ./pr-linter
- name: 'Setup reviewdog'
uses: reviewdog/action-setup@80a06617492b461a66508e2dedf16233f0506804
# Manually supply the triggering PR event information since when a PR is from a fork,
# this workflow running in the base repo will not be given information about it.
#
# Also patch the fork's owner id in the event file, since reviewdog has as fail-fast path that
# checks the head vs base repo owner id to determine if the PR is from a fork.
# If so, it assumes that it doesn't have permissions to write comments on the PR.
#
# This isn't the case in our setup since we are using two workflows (lint-csharp and this one)
# to enable write permissions on fork PRs.
- name: Submit formatting suggestions
run: |
new_event_file=${{github.workspace}}/reviewdog_event.json
jq -j ".pull_request.head.repo.owner.id = .pull_request.base.repo.owner.id" ./pr-linter/pr-event.json > ${new_event_file}
GITHUB_EVENT_NAME="pull_request" GITHUB_EVENT_PATH="${new_event_file}" reviewdog \
-name="$reporter_name" \
-f=diff \
-f.diff.strip=1 \
-reporter="github-pr-review" \
-filter-mode="diff_context" \
-fail-on-error="false" \
-level="warning" \
< "./pr-linter/linter.diff"
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}