-
Notifications
You must be signed in to change notification settings - Fork 518
79 lines (69 loc) · 3.21 KB
/
validate-prs.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
name: Validate Pull Request
on:
pull_request:
branches:
- main
types:
- labeled
- unlabeled
- opened
- reopened
- synchronize
- edited
- milestoned
- demilestoned
env:
LABELS: ${{ join( github.event.pull_request.labels.*.name, ' ' ) }}
TITLE: ${{ github.event.pull_request.title }}
NO_MILESTONE: ${{ github.event.pull_request.milestone == null }}
jobs:
js-title:
name: Check Metadata
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4 # Uploads repository content to the runner
with:
repository: "microsoft/fhir-server"
- uses: actions/labeler@v5
- uses: actions/github-script@v7
with:
script: |
var errors = "";
const title = "${{env.TITLE}}";
const body = context.payload.pull_request.body;
const labels = "${{env.LABELS}}";
if(title.toLowerCase().includes('personal') || (title.length > 65)) {
errors += '- Title of the PR to be succinct and less than 65 characters. \n';
}
if(body.toLowerCase().includes('ab#') == false && body.toLowerCase().includes('/_workitems') == false) {
errors += '- FHIR Team: A DevOps workitem is required. Use AB#123 syntax or link to DevOps item. \n';
}
if(${{env.NO_MILESTONE}}) {
errors += '- Add a milestone to the PR for the sprint that it is merged (i.e. add S47). \n';
}
if(labels.includes("Build") == false &&
labels.includes("Documentation") == false &&
labels.includes("Bug") == false &&
labels.includes("Dependencies") == false &&
labels.includes("Enhancement") == false &&
labels.includes("New Feature") == false &&
labels.includes("New-Feature") == false) {
errors += '- Tag the PR with the type of update: **Bug**, **Build**, **Dependencies**, **Enhancement**, **New Feature**, **New-Feature** or **Documentation**. \n';
}
if(labels.includes("Open source") == false &&
labels.includes("Azure API for FHIR") == false &&
labels.includes("Azure Healthcare APIs") == false &&
labels.includes("Dependencies") == false &&
labels.includes("Build") == false &&
labels.includes("Documentation") == false) {
errors += '- Tag the PR with **Open source only**, **Azure API for FHIR** (CosmosDB or common code) or **Azure Healthcare APIs** (SQL or common code) to specify where this change is intended to be released. \n';
}
if(labels.includes("SQL Scripts") == true &&
labels.includes("Schema Version backward incompatible") == false &&
labels.includes("Schema Version unchanged") == false &&
labels.includes("Schema Version backward compatible") == false) {
errors += '- Tag the PR with the type of update: **Schema Version backward incompatible**, **Schema Version backward compatible**. \n';
}
if(errors != "") {
core.setFailed(errors)
}