Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a11y-alt-text bot #989

Merged
merged 13 commits into from
Oct 30, 2023
26 changes: 26 additions & 0 deletions .github/workflows/accessibility-alt-text-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
jobs:
accessibility_alt_text_bot:
runs-on: ubuntu-latest
steps:
- if: ${{ github.event.issue || github.event.pull_request }}
uses: github/accessibility-alt-text-bot@v1.4.0

name: Accessibility Alt Text Bot

on:
issue:
types:
- created
- edited
issue_comment:
types:
- created
- edited
pull_request:
types:
- created
- edited

permissions:
issues: write
pull-requests: write
7 changes: 7 additions & 0 deletions src/steps/writing/creation/dotGitHub/createWorkflowFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ interface WorkflowFileConcurrency {
}

interface WorkflowFileOn {
issue?: {
types?: string[];
};
issue_comment?: {
types?: string[];
};
pull_request?:
| {
branches?: string | string[];
Expand All @@ -28,6 +34,7 @@ interface WorkflowFileOn {
interface WorkflowFilePermissions {
contents?: string;
"id-token"?: string;
issues?: string;
"pull-requests"?: string;
}

Expand Down
58 changes: 56 additions & 2 deletions src/steps/writing/creation/dotGitHub/createWorkflows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,33 @@ describe("createWorkflows", () => {

expect(workflows).toMatchInlineSnapshot(`
{
"accessibility-alt-text-bot.yml": "jobs:
accessibility_alt_text_bot:
runs-on: ubuntu-latest
steps:
- if: \${{ github.event.issue || github.event.pull_request }}
uses: github/accessibility-alt-text-bot@v1.4.0

name: Accessibility Alt Text Bot

on:
issue:
types:
- created
- edited
issue_comment:
types:
- created
- edited
pull_request:
types:
- created
- edited

permissions:
issues: write
pull-requests: write
",
"build.yml": "jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -218,10 +245,10 @@ describe("createWorkflows", () => {
:tada: This is included in version {release_link} :tada:

The release is available on:

* [GitHub releases](https://github.com/StubOwner/stub-repository/releases/tag/{release_tag})
* [npm package (@latest dist-tag)](https://www.npmjs.com/package/stub-repository/v/\${{ env.npm_version }})

Cheers! 📦🚀

name: Post Release
Expand Down Expand Up @@ -341,6 +368,33 @@ describe("createWorkflows", () => {

expect(workflows).toMatchInlineSnapshot(`
{
"accessibility-alt-text-bot.yml": "jobs:
accessibility_alt_text_bot:
runs-on: ubuntu-latest
steps:
- if: \${{ github.event.issue || github.event.pull_request }}
uses: github/accessibility-alt-text-bot@v1.4.0

name: Accessibility Alt Text Bot

on:
issue:
types:
- created
- edited
issue_comment:
types:
- created
- edited
pull_request:
types:
- created
- edited

permissions:
issues: write
pull-requests: write
",
"build.yml": "jobs:
build:
runs-on: ubuntu-latest
Expand Down
28 changes: 26 additions & 2 deletions src/steps/writing/creation/dotGitHub/createWorkflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,30 @@ export function createWorkflows(options: Options) {
],
}),
}),
"accessibility-alt-text-bot.yml": createWorkflowFile({
name: "Accessibility Alt Text Bot",
on: {
issue: {
types: ["created", "edited"],
},
issue_comment: {
types: ["created", "edited"],
},
pull_request: {
types: ["created", "edited"],
},
},
permissions: {
issues: "write",
"pull-requests": "write",
},
steps: [
{
if: "${{ github.event.issue || github.event.pull_request }}",
uses: "github/accessibility-alt-text-bot@v1.4.0",
},
],
}),
"lint.yml": createWorkflowFile({
name: "Lint",
runs: ["pnpm build || true", "pnpm lint"],
Expand Down Expand Up @@ -144,10 +168,10 @@ export function createWorkflows(options: Options) {
:tada: This is included in version {release_link} :tada:

The release is available on:

* [GitHub releases](https://github.com/${options.owner}/${options.repository}/releases/tag/{release_tag})
* [npm package (@latest dist-tag)](https://www.npmjs.com/package/${options.repository}/v/\${{ env.npm_version }})

Cheers! 📦🚀
`,
},
Expand Down