From 218df8fb4f61891119fb29e7e59a8fd34f0fd39c Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sun, 18 Feb 2024 11:22:59 -0500 Subject: [PATCH] ci: do not run accessibility checks for bots (#1319) ## PR Checklist - [x] Addresses an existing open issue: fixes #1318 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview See linked issue. I set this up in my repo in https://github.com/danvk/gravlax/pull/58 following https://github.com/typescript-eslint/typescript-eslint/pull/8212. We can wait for a few renovate bot updates on my repo to confirm that this has the desired effect. I added support for top-level `if` statements on jobs. It's possible to skip an individual step (which is already supported) but skipping the entire job seems more correct: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idif --- .github/workflows/accessibility-alt-text-bot.yml | 1 + src/steps/writing/creation/dotGitHub/createWorkflowFile.ts | 2 ++ src/steps/writing/creation/dotGitHub/createWorkflows.test.ts | 2 ++ src/steps/writing/creation/dotGitHub/createWorkflows.ts | 1 + 4 files changed, 6 insertions(+) diff --git a/.github/workflows/accessibility-alt-text-bot.yml b/.github/workflows/accessibility-alt-text-bot.yml index bba5c6afe..96af67f4b 100644 --- a/.github/workflows/accessibility-alt-text-bot.yml +++ b/.github/workflows/accessibility-alt-text-bot.yml @@ -1,5 +1,6 @@ jobs: accessibility_alt_text_bot: + if: ${{ !endsWith(github.actor, '[bot]') }} runs-on: ubuntu-latest steps: - uses: github/accessibility-alt-text-bot@v1.4.0 diff --git a/src/steps/writing/creation/dotGitHub/createWorkflowFile.ts b/src/steps/writing/creation/dotGitHub/createWorkflowFile.ts index e4dc32f72..534df93bb 100644 --- a/src/steps/writing/creation/dotGitHub/createWorkflowFile.ts +++ b/src/steps/writing/creation/dotGitHub/createWorkflowFile.ts @@ -49,6 +49,7 @@ interface WorkflowFileStep { interface WorkflowFileOptionsBase { concurrency?: WorkflowFileConcurrency; + if?: string; name: string; on?: WorkflowFileOn; permissions?: WorkflowFilePermissions; @@ -81,6 +82,7 @@ export function createWorkflowFile({ concurrency, jobs: { [name.replaceAll(" ", "_").toLowerCase()]: { + ...(options.if && { if: options.if }), "runs-on": "ubuntu-latest", steps: "runs" in options diff --git a/src/steps/writing/creation/dotGitHub/createWorkflows.test.ts b/src/steps/writing/creation/dotGitHub/createWorkflows.test.ts index 7f427262b..8e488e4c2 100644 --- a/src/steps/writing/creation/dotGitHub/createWorkflows.test.ts +++ b/src/steps/writing/creation/dotGitHub/createWorkflows.test.ts @@ -41,6 +41,7 @@ describe("createWorkflows", () => { { "accessibility-alt-text-bot.yml": "jobs: accessibility_alt_text_bot: + if: \${{ !endsWith(github.actor, '[bot]') }} runs-on: ubuntu-latest steps: - uses: github/accessibility-alt-text-bot@v1.4.0 @@ -351,6 +352,7 @@ describe("createWorkflows", () => { { "accessibility-alt-text-bot.yml": "jobs: accessibility_alt_text_bot: + if: \${{ !endsWith(github.actor, '[bot]') }} runs-on: ubuntu-latest steps: - uses: github/accessibility-alt-text-bot@v1.4.0 diff --git a/src/steps/writing/creation/dotGitHub/createWorkflows.ts b/src/steps/writing/creation/dotGitHub/createWorkflows.ts index f101c5ce1..f45e62c87 100644 --- a/src/steps/writing/creation/dotGitHub/createWorkflows.ts +++ b/src/steps/writing/creation/dotGitHub/createWorkflows.ts @@ -90,6 +90,7 @@ export function createWorkflows(options: Options) { }), }), "accessibility-alt-text-bot.yml": createWorkflowFile({ + if: "${{ !endsWith(github.actor, '[bot]') }}", name: "Accessibility Alt Text Bot", on: { issue_comment: {