workflows/bot: rename from labels

This workflow / script is already doing more than must labeling: it's
already auto-closing package request issues.

Since we're going to migrate the nixpkgs-merge-bot into this workflow,
we'll rename things to a more generic name.
This commit is contained in:
Wolfgang Walther 2025-10-10 16:35:00 +02:00
parent 75119422cf
commit d78de15627
No known key found for this signature in database
GPG key ID: B39893FA5F65CAE1
8 changed files with 17 additions and 17 deletions

View file

@ -1,4 +1,4 @@
# This file is used by .github/workflows/labels.yml
# This file is used by .github/workflows/bot.yml
# This version is only run for Pull Requests from development branches like staging-next, haskell-updates or python-updates.
"4.workflow: package set update":

View file

@ -1,4 +1,4 @@
# This file is used by .github/workflows/labels.yml
# This file is used by .github/workflows/bot.yml
# This version uses `sync-labels: false`, meaning that a non-match will NOT remove the label
# keep-sorted start case=no numeric=yes newline_separated=yes skip_lines=1

2
.github/labeler.yml vendored
View file

@ -1,4 +1,4 @@
# This file is used by .github/workflows/labels.yml
# This file is used by .github/workflows/bot.yml
# This version uses `sync-labels: true`, meaning that a non-match will remove the label
# keep-sorted start case=no numeric=yes newline_separated=yes skip_lines=1

View file

@ -3,7 +3,7 @@
# access to the GitHub API. This means that it should not evaluate user input in
# a way that allows code injection.
name: Labels
name: Bot
on:
schedule:
@ -21,7 +21,7 @@ on:
concurrency:
# This explicitly avoids using `run_id` for the concurrency key to make sure that only
# *one* scheduled run can run at a time.
group: labels-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number }}
group: bot-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number }}
# PR-triggered runs will be cancelled, but scheduled runs will be queued.
cancel-in-progress: ${{ github.event_name != 'schedule' }}
@ -36,7 +36,7 @@ defaults:
shell: bash
jobs:
update:
run:
runs-on: ubuntu-24.04-arm
if: github.event_name != 'schedule' || github.repository_owner == 'NixOS'
steps:
@ -64,13 +64,13 @@ jobs:
GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }}
run: gh api /rate_limit | jq
- name: Labels from API data and Eval results
- name: Run bot
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
github-token: ${{ steps.app-token.outputs.token || github.token }}
retries: 3
script: |
require('./ci/github-script/labels.js')({
require('./ci/github-script/bot.js')({
github,
context,
core,

View file

@ -100,10 +100,10 @@ jobs:
systems: ${{ needs.prepare.outputs.systems }}
testVersions: ${{ contains(fromJSON(needs.prepare.outputs.touched), 'pinned') && !contains(fromJSON(needs.prepare.outputs.headBranch).type, 'development') }}
labels:
name: Labels
bot:
name: Bot
needs: [prepare, eval]
uses: ./.github/workflows/labels.yml
uses: ./.github/workflows/bot.yml
permissions:
issues: write
pull-requests: write

View file

@ -58,10 +58,10 @@ jobs:
if (files.some(file => [
'.github/actions/checkout/action.yml',
'.github/workflows/bot.yml',
'.github/workflows/build.yml',
'.github/workflows/check.yml',
'.github/workflows/eval.yml',
'.github/workflows/labels.yml',
'.github/workflows/lint.yml',
'.github/workflows/pull-request-target.yml',
'.github/workflows/reviewers.yml',

View file

@ -484,7 +484,7 @@ module.exports = async ({ github, context, core, dry }) => {
const lastRun = (
await github.rest.actions.listWorkflowRuns({
...context.repo,
workflow_id: 'labels.yml',
workflow_id: 'bot.yml',
event: 'schedule',
status: 'success',
exclude_pull_requests: true,

View file

@ -65,19 +65,19 @@ program
})
program
.command('labels')
.description('Manage labels on pull requests.')
.command('bot')
.description('Run automation on pull requests and issues.')
.argument('<owner>', 'Owner of the GitHub repository to label (Example: NixOS)')
.argument('<repo>', 'Name of the GitHub repository to label (Example: nixpkgs)')
.argument('[pr]', 'Number of the Pull Request to label')
.option('--no-dry', 'Make actual modifications')
.action(async (owner, repo, pr, options) => {
const labels = (await import('./labels.js')).default
const bot = (await import('./bot.js')).default
const tmp = mkdtempSync(join(tmpdir(), 'github-script-'))
try {
process.env.GITHUB_WORKSPACE = tmp
process.chdir(tmp)
await run(labels, owner, repo, pr, options)
await run(bot, owner, repo, pr, options)
} finally {
rmSync(tmp, { recursive: true })
}