diff --git a/.github/scripts/do-not-merge-block.js b/.github/scripts/do-not-merge-block.js deleted file mode 100644 index 01d72bc..0000000 --- a/.github/scripts/do-not-merge-block.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Fails the workflow if any of the specified labels are present on the PR. - * - * Inputs (via environment): - * FAIL_LABELS: comma-separated list of labels to check (default: "do-not-merge") - */ - -module.exports = async ({ context, core }) => { - const failLabels = (process.env.FAIL_LABELS || "do-not-merge") - .split(",") - .map((l) => l.trim().toLowerCase()) - .filter(Boolean); - - const pr = context.payload.pull_request; - if (!pr) { - core.info("This action is only applicable to pull requests."); - return; - } - - const prLabels = (pr.labels || []).map((l) => l.name.toLowerCase()); - const found = failLabels.find((label) => prLabels.includes(label)); - - if (found) { - const msg = `❌ This PR has a label that blocks merging: \`${found}\`.\nPlease remove the label to proceed.`; - core.summary.addRaw(msg); - core.setFailed(msg); - return; - } - - core.info(`No blocking labels found. Blocking labels checked: [${failLabels.join(", ")}]`); -}; diff --git a/.github/workflows/do-not-merge-block.yml b/.github/workflows/do-not-merge-block.yml deleted file mode 100644 index 40a768c..0000000 --- a/.github/workflows/do-not-merge-block.yml +++ /dev/null @@ -1,48 +0,0 @@ -### -# This workflow fails if a PR has a blocking label (e.g., "do-not-merge"). -# -# To customize blocking labels, set the FAIL_LABELS variable (comma-separated). -# Default: "do-not-merge" -# -# To set the variable, you can use the GitHub CLI: -# gh variable set FAIL_LABELS --body "do-not-merge,dnm" -### - -name: Do Not Merge Blocker - -on: - pull_request: - types: [opened, labeled, unlabeled] - merge_group: - -permissions: {} - -env: - PATH_TO_REPO_SELF: gha-org-workflows - -jobs: - do-not-merge-block: - name: Do Not Merge Block - runs-on: ubuntu-latest - timeout-minutes: 5 - permissions: - contents: read - # Skip on merge group events - if: ${{ github.event_name == 'pull_request' }} - steps: - - name: Checkout org workflows - uses: actions/checkout@v4 - with: - repository: smartcontractkit/${{ env.PATH_TO_REPO_SELF}} - path: ${{ env.PATH_TO_REPO_SELF}} - persist-credentials: false - - - name: Fail if blocking label present - uses: actions/github-script@v7 - env: - FAIL_LABELS: ${{ vars.DO_NOT_MERGE_LABELS || 'do-not-merge' }} - with: - script: | - const pathToRepoSelf = process.env.PATH_TO_REPO_SELF || 'gha-org-workflows'; - const script = require(`./${pathToRepoSelf}/.github/scripts/do-not-merge-block.js`); - await script({ context, core });