2022-09-23 10:13:03 -05:00
|
|
|
name: Check mergeability
|
|
|
|
|
2023-05-31 17:15:14 -05:00
|
|
|
on: pull_request
|
2022-09-23 10:13:03 -05:00
|
|
|
|
|
|
|
permissions:
|
|
|
|
pull-requests: write
|
2023-05-31 17:15:14 -05:00
|
|
|
checks: write
|
|
|
|
statuses: write
|
|
|
|
|
2022-09-23 10:13:03 -05:00
|
|
|
jobs:
|
|
|
|
check:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Check if there is already a block on this PR
|
|
|
|
id: set-blocks
|
2022-10-28 10:39:01 -05:00
|
|
|
uses: actions/github-script@v6
|
2023-05-31 17:15:14 -05:00
|
|
|
env:
|
|
|
|
issue_number: ${{ github.event.number }}
|
2022-10-28 10:39:01 -05:00
|
|
|
with:
|
|
|
|
script: |
|
2023-05-31 17:15:14 -05:00
|
|
|
const { data: reviews } = await github.rest.pulls.listReviews({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
pull_number: process.env.issue_number,
|
|
|
|
});
|
|
|
|
console.log(reviews);
|
|
|
|
for (const review of reviews) {
|
|
|
|
if (review.user.id === 41898282 && review.state === 'CHANGES_REQUESTED') {
|
2022-10-28 10:39:01 -05:00
|
|
|
return 'block';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
result-encoding: string
|
2022-09-23 10:13:03 -05:00
|
|
|
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
if: steps.set-blocks.outputs.blocks == ''
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Get changed files in the .changeset folder
|
|
|
|
id: changed-files
|
2023-05-04 05:31:31 -05:00
|
|
|
uses: tj-actions/changed-files@v35
|
2022-09-23 10:13:03 -05:00
|
|
|
if: steps.set-blocks.outputs.blocks == ''
|
|
|
|
with:
|
|
|
|
files: |
|
|
|
|
.changeset/**/*.md
|
|
|
|
|
|
|
|
- name: Check if any changesets contain minor changes
|
|
|
|
id: find-blockers
|
|
|
|
if: steps.set-blocks.outputs.blocks == ''
|
|
|
|
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
|
2023-05-31 17:15:14 -05:00
|
|
|
uses: actions/github-script@v6
|
2022-09-23 10:13:03 -05:00
|
|
|
if: steps.find-blockers.outputs.found == 'true'
|
2023-05-31 17:15:14 -05:00
|
|
|
env:
|
|
|
|
issue_number: ${{ github.event.number }}
|
2023-04-06 09:29:55 -05:00
|
|
|
with:
|
2023-05-31 17:15:14 -05:00
|
|
|
script: |
|
|
|
|
github.rest.issues.addLabels({
|
|
|
|
issue_number: process.env.issue_number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
labels: ['semver minor']
|
|
|
|
});
|
2023-04-06 09:29:55 -05:00
|
|
|
|
2023-05-31 17:15:14 -05:00
|
|
|
- name: Change PR Status
|
|
|
|
uses: actions/github-script@v6
|
2022-09-23 10:13:03 -05:00
|
|
|
if: steps.find-blockers.outputs.found == 'true'
|
2023-05-31 17:15:14 -05:00
|
|
|
env:
|
|
|
|
issue_number: ${{ github.event.number }}
|
2023-03-01 11:23:24 -05:00
|
|
|
with:
|
2023-05-31 17:15:14 -05:00
|
|
|
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.'
|
|
|
|
});
|
2023-04-06 09:29:55 -05:00
|
|
|
|