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