Fix duplicate semver minor blocks (#7269)

* chore(action): fix duplicate blocks

* chore(action): fix block logic
This commit is contained in:
Nate Moore 2023-06-01 13:21:55 -05:00 committed by GitHub
parent 5156c4f90e
commit 408be72d1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check if there is already a block on this PR - name: Check if there is already a block on this PR
id: set-blocks id: blocked
uses: actions/github-script@v6 uses: actions/github-script@v6
env: env:
issue_number: ${{ github.event.number }} issue_number: ${{ github.event.number }}
@ -23,31 +23,31 @@ jobs:
repo: context.repo.repo, repo: context.repo.repo,
pull_number: process.env.issue_number, pull_number: process.env.issue_number,
}); });
console.log(reviews);
for (const review of reviews) { for (const review of reviews) {
if (review.user.id === 41898282 && review.state === 'CHANGES_REQUESTED') { if (review.user.login === 'github-actions[bot]' && review.state === 'CHANGES_REQUESTED') {
return 'block'; return 'true'
} }
} }
return ''; return 'false'
result-encoding: string result-encoding: string
- uses: actions/checkout@v3 - uses: actions/checkout@v3
if: steps.set-blocks.outputs.blocks == '' if: steps.blocked.outputs.result != 'true'
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Get changed files in the .changeset folder - name: Get changed files in the .changeset folder
id: changed-files id: changed-files
uses: tj-actions/changed-files@v35 uses: tj-actions/changed-files@v35
if: steps.set-blocks.outputs.blocks == '' if: steps.blocked.outputs.result != 'true'
with: with:
files: | files: |
.changeset/**/*.md .changeset/**/*.md
- name: Check if any changesets contain minor changes - name: Check if any changesets contain minor changes
id: find-blockers id: minor
if: steps.set-blocks.outputs.blocks == '' if: steps.blocked.outputs.result != 'true'
run: | run: |
echo "Checking for changesets marked as minor" echo "Checking for changesets marked as minor"
echo '::set-output name=found::false' echo '::set-output name=found::false'
@ -60,7 +60,7 @@ jobs:
- name: Add label - name: Add label
uses: actions/github-script@v6 uses: actions/github-script@v6
if: steps.find-blockers.outputs.found == 'true' if: steps.minor.outputs.found == 'true'
env: env:
issue_number: ${{ github.event.number }} issue_number: ${{ github.event.number }}
with: with:
@ -74,7 +74,7 @@ jobs:
- name: Change PR Status - name: Change PR Status
uses: actions/github-script@v6 uses: actions/github-script@v6
if: steps.find-blockers.outputs.found == 'true' if: steps.minor.outputs.found == 'true'
env: env:
issue_number: ${{ github.event.number }} issue_number: ${{ github.event.number }}
with: with:
@ -86,4 +86,3 @@ jobs:
event: 'REQUEST_CHANGES', 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.' body: 'This PR is blocked because it contains a `minor` changeset. A reviewer will merge this at the next release if approved.'
}); });