From 3ffd8ee1a968c8e8607f9625697128f67bdc6d8a Mon Sep 17 00:00:00 2001 From: Kersom <9053044+nixocio@users.noreply.github.com> Date: Tue, 23 Sep 2025 11:46:05 -0400 Subject: [PATCH] Remove Dependabot and automerge workflows (#5536) Remove Dependabot and automerge workflows --- .github/workflows/automerge-condition.js | 28 ------ .github/workflows/automerge-wait.js | 104 ----------------------- .github/workflows/automerge.yml | 39 --------- 3 files changed, 171 deletions(-) delete mode 100644 .github/workflows/automerge-condition.js delete mode 100644 .github/workflows/automerge-wait.js delete mode 100644 .github/workflows/automerge.yml diff --git a/.github/workflows/automerge-condition.js b/.github/workflows/automerge-condition.js deleted file mode 100644 index 95bd6c6617..0000000000 --- a/.github/workflows/automerge-condition.js +++ /dev/null @@ -1,28 +0,0 @@ -// get these values from env instead of cli args due to RCE issues -const actor = process.env.GITHUB_ACTOR; -const branch = process.env.GITHUB_HEAD_REF; -const prTitle = process.env.PR_TITLE; - -console.log({ actor, branch, prTitle }); - -if (actor != 'dependabot[bot]') { - console.log('Actor incorrect (GITHUB_ACTOR)'); - process.exit(1); -} - -if (!branch) { - console.log('Branch name not set (GITHUB_HEAD_REF)'); - process.exit(1); -} - -if (!prTitle) { - console.log('PR title not set (PR_TITLE)'); - process.exit(1); -} - -if (prTitle.includes('@types/node') && !prTitle.match(/from (\d+)\.\d+\.\d+ to \1\.\d+\.\d+/)) { - console.log('Not automerging major @types/node version bump'); - process.exit(1); -} - -process.exit(0); diff --git a/.github/workflows/automerge-wait.js b/.github/workflows/automerge-wait.js deleted file mode 100644 index 8326f58b21..0000000000 --- a/.github/workflows/automerge-wait.js +++ /dev/null @@ -1,104 +0,0 @@ -const { exec } = require('node:child_process'); - -// get these values from env instead of cli args due to RCE issues -const branch = process.env.GITHUB_HEAD_REF; - -if (!branch) { - console.log('Branch name not set (GITHUB_HEAD_REF)'); - process.exit(1); -} - -let waitCount = 0; - -function waitForAll() { - waitCount++; - - // fail after 30 minutes - if (waitCount > 30) { - console.log('Waiting limit reached. Exiting.'); - process.exit(1); - } - - // name,status,conclusion,event,displayTitle,workflowName,createdAt,startedAt,updatedAt,headSha,databaseId,workflowDatabaseId - console.log('run exec'); - exec( - `gh run list -b "${branch}" --limit 99999 --json name,status,conclusion,event,displayTitle,workflowName,createdAt,startedAt,updatedAt,headSha,databaseId,workflowDatabaseId`, - (error, stdout, stderr) => { - console.log('inside exec'); - - if (error) { - console.log(`error: ${error.message}`); - process.exit(1); - } - if (stderr) { - console.log(`stderr: ${stderr}`); - process.exit(1); - } - - console.log('parse data'); - - data = JSON.parse(stdout); - - let allSuccess = true; - let allCompleted = true; - - console.log('Items found: ' + data.length); - - // select unique names - let workflows = data - .filter( - (a) => - a.workflowName != 'Automerge' && - a.workflowName != 'Add labels to pull request', - ) - .map((a) => a.workflowName); - workflows = [...new Set(workflows)]; - console.log('distinct workflows'); - console.log(workflows); - console.log('end of distinct workflows'); - - console.log('latest items:'); - - let latest = []; - workflows.forEach((workflow) => { - let items = data - .filter((a) => a.workflowName == workflow) - .sort((a, b) => a.startedAt > b.startedAt); - latest.push(items[0]); - console.log(items[0]); - }); - - latest.forEach((item) => { - if (item.conclusion != 'success') { - allSuccess = false; - } - if (item.status != 'completed') { - allCompleted = false; - } - console.log( - item.name + ' is ' + item.status + ' with result ' + item.conclusion, - ); - }); - - console.log('All completed: ' + allCompleted); - console.log('All success: ' + allSuccess); - - if (allCompleted && allSuccess) { - console.log('All checks has completed succesfuly,.'); - process.exit(0); - } - - if (allCompleted && !allSuccess) { - console.log( - 'Not all checks has completed succesfuly, automerge failed.', - ); - process.exit(1); - } - - // retry after a minute - setTimeout(waitForAll, 60000); - }, - ); -} - -waitForAll(); diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml deleted file mode 100644 index 545b7c3e1c..0000000000 --- a/.github/workflows/automerge.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Automerge - -on: - pull_request_target: - branches: [ 'stable-*' ] - -jobs: - automerge: - if: github.actor == 'dependabot[bot]' - runs-on: ubuntu-latest - steps: - - - name: "Checkout ansible-hub-ui (${{ github.ref }})" - uses: actions/checkout@v4 - - - name: "Install node 20" - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: "Check automerge conditions" - working-directory: ".github/workflows" - env: - PR_TITLE: "${{ github.event.pull_request.title }}" - run: | - node automerge-condition.js - - - name: "Wait for other tests" - working-directory: ".github/workflows" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - node automerge-wait.js - - - name: "Automerge the PR" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh pr merge "${{ github.event.pull_request.number }}" -s --auto