-
-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (128 loc) · 4.68 KB
/
pr-check.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Pull Request check
on:
pull_request:
types:
- opened
- synchronize
jobs:
say-hi:
continue-on-error: true
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Check for existence of comment
id: comment
run: |
yarn init --yes
yarn add --optional @octokit/[email protected]
node --eval="
(async function() {
const { Octokit } = require('@octokit/rest');
const github = new Octokit({ auth: process.env.GITHUB_TOKEN });
const issueNumber = '${{ github.event.pull_request.number }}';
const owner = '${{ github.repository_owner }}';
const repo = '${{ github.repository }}'.replace(owner + '/', '');
const { data: comments } = await github.issues.listComments({
owner,
repo,
issue_number: issueNumber,
});
console.log(comments.some(comment => comment.body.includes('Hi, ${{ github.actor }}')));
})();
" >> hi.txt
echo "result=$(cat hi.txt | grep -E 'true|false')" >> $GITHUB_OUTPUT
- name: Say hi
uses: jungwinter/comment@v1
if: steps.comment.outputs.result == 'false'
with:
type: create
token: ${{ secrets.GITHUB_TOKEN }}
issue_number: ${{ github.event.pull_request.number }}
body: |
Hi, ${{ github.actor }}!
Make sure to comply with the [Code of Conduct](https://github.com/${{ github.repository }}/blob/main/CODE_OF_CONDUCT.md), [security policy](https://github.com/${{ github.repository }}/blob/main/SECURITY.md) and [contribution guidelines](https://github.com/${{ github.repository }}/blob/main/CONTRIBUTING.md) before contributing to this repo.
test:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Install dependencies
run: yarn
- name: Validate package.json
run: yarn validate-package-json
- name: Validate Markdown links
run: yarn check-links
- name: Run ESLint
run: yarn lint
- name: Build code
run: yarn build
- name: Run main test suites
run: yarn test
- name: Checkout main
if: failure()
run: git clone https://github.com/${{ github.repository }} main/
- name: Report build failed (if any)
if: failure()
uses: ./main/.github/workflows/pr-build-failed.yml
with:
pr-author: ${{ github.event.pull_request.user.login }}
number: ${{ github.event.pull_request.number }}
assign-and-ping:
runs-on: ubuntu-latest
continue-on-error: true
needs: test
if: success()
permissions:
pull-requests: write
issues: write
steps:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 19.x
- name: Assign pull request to yourself
run: |
yarn init --yes
yarn add --optional @octokit/[email protected]
node --eval="
const { Octokit } = require('@octokit/rest');
const github = new Octokit({ auth: process.env.GITHUB_TOKEN });
(async function() {
await github.issues.addAssignees({
owner: '${{ github.repository_owner }}',
repo: '${{ github.repository }}'.replace('${{ github.repository_owner }}/', ''),
issue_number: ${{ github.event.pull_request.number }},
assignees: ['${{ github.repository_owner }}'],
});
})();
"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Request code review
run: |
yarn init --yes
yarn add --optional @octokit/[email protected]
node --eval="
const { Octokit } = require('@octokit/rest');
const github = new Octokit({ auth: process.env.GITHUB_TOKEN });
(async function() {
await github.pulls.requestReviewers({
owner: '${{ github.repository_owner }}',
repo: '${{ github.repository }}'.replace('${{ github.repository_owner }}/', ''),
pull_number: ${{ github.event.pull_request.number }},
reviewers: ['${{ github.repository_owner }}'],
});
})();
"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}