Skip to content

Instantly share code, notes, and snippets.

@kjaymiller
Last active December 21, 2023 19:08
Show Gist options
  • Save kjaymiller/af11a3ee6ef1d56500290b2a05c994c1 to your computer and use it in GitHub Desktop.
Save kjaymiller/af11a3ee6ef1d56500290b2a05c994c1 to your computer and use it in GitHub Desktop.
Ruff and MarkdownLint GH Action
name: Format and Lint with Ruff and MarkdownLint
on:
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
# Update output format to enable automatic inline annotations.
- name: Run Ruff
run: |
ruff check --fix --output-format=github .
ruff format .
- name: Markdown Lint base-files
uses: DavidAnson/markdownlint-cli2-action@v14
with:
fix: true
globs: |
*.md
.github/**/*.md
continue-on-error: true
- name: Markdown Lint Docs
uses: DavidAnson/markdownlint-cli2-action@v14
with:
fix: true
globs: docs/**/*.md
config: docs/.markdownlint.json
continue-on-error: true
- name: Commit changes
run: |
if [ -n "$(git status --porcelain)" ]; then
git config --global user.name "Ruff"
git config --global user.email "ruff-action@users.noreply.github.com"
git add -A
git commit -m "Format and lint with Ruff"
git push origin HEAD:${{ github.event.pull_request.head.ref }}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment