forked from napari/napari
-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (63 loc) · 2.79 KB
/
label_and_milestone_checker.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
name: Labels and milestone
on:
pull_request:
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled
- milestoned
- demilestoned
merge_group: # to be prepared on merge queue
types: [checks_requested]
jobs:
check_labels:
if: (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ready to merge'))
name: Check ready-to-merge PR has at least one type label
runs-on: ubuntu-latest
steps:
- name: Check labels
uses: docker://agilepathway/pull-request-label-checker:latest
with:
any_of: bugfix,feature,documentation,performance,enhancement,maintenance
repo_token: ${{ secrets.GITHUB_TOKEN }}
check_next_milestone:
name: Check milestone is next release
if: (github.event_name == 'pull_request' && github.event.pull_request.milestone != null)
runs-on: ubuntu-latest
steps:
- name: Check milestone for closest due date
env:
GH_TOKEN: ${{ github.token }}
PR_MILESTONE_NAME: ${{ github.event.pull_request.milestone.title }}
run: |
# Install GitHub CLI if necessary
# sudo apt-get install -y gh
IFS='/' read -r repoOwner repoName <<< "${{ github.repository }}"
# Fetch the closest future milestone
# shellcheck disable=SC2016
CLOSEST_MILESTONE=$(gh api graphql -f query='
query($repoName: String!, $repoOwner: String!) {
repository(name: $repoName, owner: $repoOwner) {
milestones(states: OPEN, orderBy: {field: DUE_DATE, direction: ASC}, first: 100) {
nodes {
title
number
dueOn
}
}
}
}' --jq '.data.repository.milestones.nodes | map(select(.dueOn >= now)) | .[0].number' -f repoName="$repoName" -f repoOwner="$repoOwner")
# Extract the milestone number of the current PR
PR_MILESTONE_NUMBER=$(gh api "/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" --jq '.milestone.number')
CLOSEST_MILESTONE_NAME=$(gh api "/repos/${{ github.repository }}/milestones/$CLOSEST_MILESTONE" --jq '.title')
# Check if the PR's milestone is the closest future milestone
if [ "$CLOSEST_MILESTONE" != "$PR_MILESTONE_NUMBER" ]; then
echo "If this PR can be merged in time for the earlier milestone,"
echo "changing the milestone to $CLOSEST_MILESTONE_NAME will make the check pass."
echo "If this PR must wait until $PR_MILESTONE_NAME,"
echo "remove the ready-to-merge tag to skip this check,"
echo "and re-add it when all earlier milestones are completed."
exit 1
fi