Skip to content

[skill-activity] Reduce cognitive load in GitHub Actions intro #2910

[skill-activity] Reduce cognitive load in GitHub Actions intro

[skill-activity] Reduce cognitive load in GitHub Actions intro #2910

Workflow file for this run

name: Markdown Lint
on:
pull_request:
paths:
- "**/*.md"
- ".markdownlint-cli2.yaml"
- ".github/workflows/markdown-lint.yml"
push:
branches:
- main
paths:
- "**/*.md"
- ".markdownlint-cli2.yaml"
- ".github/workflows/markdown-lint.yml"
permissions:
contents: read
issues: write
jobs:
markdownlint:
name: Lint Markdown (GFM)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Lint markdown
id: lint
continue-on-error: true
uses: DavidAnson/markdownlint-cli2-action@6bf21b07787794f89a243495939cd651942aeabe # v24.1.0
with:
globs: |
**/*.md
- name: File issue for lint failure on main
if: steps.lint.outcome == 'failure' && github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const title = 'Markdown lint failure on main'
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
const body = [
'The markdown lint workflow failed on `main`.',
'',
`Workflow run: ${runUrl}`,
'',
'Please fix the markdown linting errors reported in this run.',
].join('\n')
const { owner, repo } = context.repo
const { data: searchResults } = await github.rest.search.issuesAndPullRequests({
q: `repo:${owner}/${repo} is:issue is:open in:title "${title}"`,
per_page: 10,
})
const existingIssue = searchResults.items.find(
(issue) => issue.title === title
)
if (existingIssue) {
await github.rest.issues.createComment({
owner,
repo,
issue_number: existingIssue.number,
body,
})
} else {
await github.rest.issues.create({
owner,
repo,
title,
body,
})
}
- name: Fail job when lint fails
if: steps.lint.outcome == 'failure'
run: exit 1