2022-09-23 10:13:03 -05:00
|
|
|
name: Check mergeability
|
|
|
|
|
|
|
|
on: pull_request # run on pull request events
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
# grant write permission on the pull-requests endpoint
|
|
|
|
pull-requests: write
|
|
|
|
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
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const url = 'https://api.github.com/repos/' + context.repo.owner + '/' + context.repo.repo + '/pulls/' + context.issue.number + '/reviews';
|
|
|
|
console.log('reviews URL', url);
|
|
|
|
const result = await github.request(url);
|
|
|
|
console.log(result);
|
|
|
|
const reviews = result.data;
|
|
|
|
for(const review of reviews) {
|
|
|
|
if(review.user.id === 41898282 && review.state === 'CHANGES_REQUESTED') {
|
|
|
|
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
|
|
|
|
uses: tj-actions/changed-files@v29
|
|
|
|
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
|
|
|
|
if: steps.find-blockers.outputs.found == 'true'
|
|
|
|
run: |
|
|
|
|
curl --request POST \
|
|
|
|
--url https://api.github.com/repos/${{github.repository}}/issues/${{github.event.number}}/labels \
|
|
|
|
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
|
|
|
|
--header 'content-type: application/json' \
|
|
|
|
-d '["semver minor"]'
|
|
|
|
|
|
|
|
- name: Send PR review
|
|
|
|
if: steps.find-blockers.outputs.found == 'true'
|
2023-03-01 11:23:24 -05:00
|
|
|
uses: peter-evans/create-or-update-comment@v2
|
|
|
|
continue-on-error: true
|
|
|
|
with:
|
|
|
|
issue-number: ${{ github.event.issue.number }}
|
|
|
|
body: |
|
|
|
|
This PR is blocked because it contains a `minor` changeset. A reviewer will merge this at the next release if approved.
|
|
|
|
edit-mode: replace
|