0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00
astro/.github/workflows/check-merge.yml
Nate Moore c4c086e5e7
Fix semver minor action (#7261)
* Update check-merge.yml

* chore: update action

* chore(action): better check if block exists

* chore(action): update check-merge action
2023-05-31 17:15:14 -05:00

89 lines
2.8 KiB
YAML

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: set-blocks
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,
});
console.log(reviews);
for (const review of reviews) {
if (review.user.id === 41898282 && review.state === 'CHANGES_REQUESTED') {
return 'block';
}
}
return '';
result-encoding: string
- 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@v35
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
uses: actions/github-script@v6
if: steps.find-blockers.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.find-blockers.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.'
});