Skip to content

Commit

Permalink
workflows: notify on manual autobump
Browse files Browse the repository at this point in the history
  • Loading branch information
iMichka committed Feb 13, 2024
1 parent ce24afc commit daaf971
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/scripts/check-autobump.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const fs = require('fs')
const path = require('path');

module.exports = async ({github, context, core}, autobump_list) => {
// Parse event
const json = fs.readFileSync(process.env.GITHUB_EVENT_PATH, { encoding: "utf-8" })
const event = JSON.parse(json)
const pull = event.pull_request

// Fetch PR files
const files = await github.rest.pulls.listFiles({
...context.repo,
pull_number: pull.number
})

const autobump_array = autobump_list.split(" ")

for (const file of files.data) {
if(autobump_array.includes(path.parse(file.filename).name)) {
github.rest.issues.createComment({
...context.repo,
issue_number: pull.number,
body: `
Hi! You have used \`brew bump-formula-pr\` on a formula that is on the autobump list.
No need to manually bump it, BrewTestBot will automatically create an equivalent pull reques for you!
We prefer that you spend time fixing broken pull requests instead of manually bumping formulae.`
});
}
}
}
24 changes: 24 additions & 0 deletions .github/workflows/triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ env:
GH_REPO: ${{ github.repository }}
GH_NO_UPDATE_NOTIFIER: 1
GH_PROMPT_DISABLED: 1
SCRIPTS_PATH: .github/workflows/scripts

concurrency:
group: "triage-${{ github.event.number }}"
Expand Down Expand Up @@ -227,3 +228,26 @@ jobs:
- label: pip-audit
pr_body_content: Created by `brew-pip-audit`
- name: Get list of autobump formulae
id: autobump
run: echo "autobump_list=$(xargs < "$GITHUB_WORKSPACE"/.github/autobump.txt)" >> "$GITHUB_OUTPUT"

- name: Prevent manual autobump
#if: >
# github.actor != 'BrewTestBot' &&
# contains(github.event.pull_request.labels.*.name, 'brew bump-formula-pr')
uses: actions/github-script@v7
env:
AUTOBUMPED_FORMULAE: ${{steps.autobump.outputs.autobump_list}}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const path = require('path')
const script = require(path.resolve(`${process.env.SCRIPTS_PATH}/check-autobump.js`))
try {
await script({github, context, core}, `${process.env.AUTOBUMPED_FORMULAE}`)
} catch (error) {
console.error(error);
}

0 comments on commit daaf971

Please sign in to comment.