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
|
2023-06-01 13:21:55 -05:00
|
|
|
id: blocked
|
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,
|
|
|
|
});
|
2023-06-01 13:21:55 -05:00
|
|
|
|
2023-05-31 17:15:14 -05:00
|
|
|
for (const review of reviews) {
|
2023-06-01 13:21:55 -05:00
|
|
|
if (review.user.login === 'github-actions[bot]' && review.state === 'CHANGES_REQUESTED') {
|
|
|
|
return 'true'
|
2022-10-28 10:39:01 -05:00
|
|
|
}
|
|
|
|
}
|
2023-06-01 13:21:55 -05:00
|
|
|
return 'false'
|
2022-10-28 10:39:01 -05:00
|
|
|
result-encoding: string
|
2022-09-23 10:13:03 -05:00
|
|
|
|
|
|
|
- uses: actions/checkout@v3
|
2023-06-01 13:21:55 -05:00
|
|
|
if: steps.blocked.outputs.result != 'true'
|
2022-09-23 10:13:03 -05:00
|
|
|
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
|
2023-06-01 13:21:55 -05:00
|
|
|
if: steps.blocked.outputs.result != 'true'
|
2022-09-23 10:13:03 -05:00
|
|
|
with:
|
|
|
|
files: |
|
|
|
|
.changeset/**/*.md
|
|
|
|
|
|
|
|
- name: Check if any changesets contain minor changes
|
2023-06-01 13:21:55 -05:00
|
|
|
id: minor
|
|
|
|
if: steps.blocked.outputs.result != 'true'
|
2022-09-23 10:13:03 -05:00
|
|
|
run: |
|
|
|
|
echo "Checking for changesets marked as minor"
|
2024-01-03 01:20:38 -05:00
|
|
|
echo "found=false" >> $GITHUB_OUTPUT
|
2022-09-23 10:13:03 -05:00
|
|
|
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
|
|
|
|
if grep -q "'astro': minor" "$file"; then
|
2024-01-03 01:20:38 -05:00
|
|
|
echo "found=true" >> $GITHUB_OUTPUT
|
2022-09-23 10:13:03 -05:00
|
|
|
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
|
2023-06-01 13:21:55 -05:00
|
|
|
if: steps.minor.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,
|
2023-07-17 14:14:33 -05:00
|
|
|
labels: ['semver: minor']
|
2023-05-31 17:15:14 -05:00
|
|
|
});
|
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
|
2023-06-01 13:21:55 -05:00
|
|
|
if: steps.minor.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.'
|
|
|
|
});
|