-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
88 lines (79 loc) · 2.73 KB
/
check-merge.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
name: Check mergeability
on: pull_request
permissions:
pull-requests: write
checks: write
statuses: write
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Check if there is already a block on this PR
id: blocked
uses: actions/github-script@v6
env:
issue_number: ${{ github.event.number }}
with:
script: |
const { data: reviews } = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: process.env.issue_number,
});
for (const review of reviews) {
if (review.user.login === 'github-actions[bot]' && review.state === 'CHANGES_REQUESTED') {
return 'true'
}
}
return 'false'
result-encoding: string
- uses: actions/checkout@v3
if: steps.blocked.outputs.result != 'true'
with:
fetch-depth: 0
- name: Get changed files in the .changeset folder
id: changed-files
uses: tj-actions/changed-files@v35
if: steps.blocked.outputs.result != 'true'
with:
files: |
.changeset/**/*.md
- name: Check if any changesets contain minor changes
id: minor
if: steps.blocked.outputs.result != 'true'
run: |
echo "Checking for changesets marked as minor"
echo '::set-output name=found::false'
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if grep -q "'astro': minor" "$file"; then
echo '::set-output name=found::true'
echo "$file has a minor release tag"
fi
done
- name: Add label
uses: actions/github-script@v6
if: steps.minor.outputs.found == 'true'
env:
issue_number: ${{ github.event.number }}
with:
script: |
github.rest.issues.addLabels({
issue_number: process.env.issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['semver: minor']
});
- name: Change PR Status
uses: actions/github-script@v6
if: steps.minor.outputs.found == 'true'
env:
issue_number: ${{ github.event.number }}
with:
script: |
github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: process.env.issue_number,
event: 'REQUEST_CHANGES',
body: 'This PR is blocked because it contains a `minor` changeset. A reviewer will merge this at the next release if approved.'
});