name: Lint GitHub Actions workflows

# yamllint disable-line rule:truthy
on: [push, pull_request]

permissions: read-all

jobs:
  actionlint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
      - name: Download actionlint
        id: get_actionlint
        # yamllint disable-line rule:line-length
        run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
        shell: bash
      - name: Check workflow files
        run: ${{ steps.get_actionlint.outputs.executable }} -color
        shell: bash

  pre-commit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
      - name: Install pre-commit
        shell: bash
        run: |
          python -m pip install pre-commit
      - name: Run pre-commit
        run: |
          pre-commit install
          pre-commit run --all-files
