Skip to content

Commit

Permalink
ci: do not run accessibility checks for bots (#1319)
Browse files Browse the repository at this point in the history
## 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
danvk/gravlax#58 following
typescript-eslint/typescript-eslint#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
  • Loading branch information
danvk authored Feb 18, 2024
1 parent 9144884 commit 218df8f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/accessibility-alt-text-bot.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/steps/writing/creation/dotGitHub/createWorkflowFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ interface WorkflowFileStep {

interface WorkflowFileOptionsBase {
concurrency?: WorkflowFileConcurrency;
if?: string;
name: string;
on?: WorkflowFileOn;
permissions?: WorkflowFilePermissions;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/steps/writing/creation/dotGitHub/createWorkflows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/steps/writing/creation/dotGitHub/createWorkflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 218df8f

Please sign in to comment.