diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9d59d8c907..f28435716b 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -449,6 +449,32 @@ jobs: apa-proxy: ${{ matrix.e2e-test.apa-proxy }} deps: ${{ matrix.e2e-test.deps }} + PR-forbidden-labels: + runs-on: ubuntu-latest + steps: + - id: checkoutRepo + name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 1 + - name: PR contains forbidden labels + id: pr-forbidden + uses: actions/github-script@v6 + with: + script: | + const issueHasLabels = require('./scripts/github/update/check-issue-has-label.js'); + const checkLabels = ['next version ➡️', 'do not merge🙅🏻‍♂️']; + + const hasLabel = await issueHasLabels({github, context, checkLabels}) + + if(hasLabel) { + core.setFailed('The PR contains a forbidden label! You are not allowed to merge until the label is there.'); + } + - name: Check value after + run: | + echo "result ${{ toJson(steps.pr-forbidden.*.result) }}" && echo "result ${{ steps.pr-forbidden.*.result }}" + echo "result ${{ contains(toJson(steps.pr-forbidden.*.result), 'failure') }}" + finalize: if: ${{ always() }} runs-on: ubuntu-latest diff --git a/scripts/github/update/check-issue-has-label.js b/scripts/github/update/check-issue-has-label.js new file mode 100755 index 0000000000..5a1184492d --- /dev/null +++ b/scripts/github/update/check-issue-has-label.js @@ -0,0 +1,14 @@ +module.exports = async ({ github, context, checkLabels }) => { + const { data: issue } = await github.rest.issues.get({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + const labels = issue.labels?.map(item => item.name); + + if (checkLabels.some(i => labels.includes(i))) { + return true; + } + return false; +} + \ No newline at end of file