Skip to content

greenc-FNAL checking Markdown format #766

greenc-FNAL checking Markdown format

greenc-FNAL checking Markdown format #766

Workflow file for this run

name: Markdown Check
run-name: "${{ github.actor }} checking Markdown format"
permissions:
contents: read
pull-requests: read
"on":
pull_request:
workflow_dispatch:
inputs:
ref:
description: "The branch, ref, or SHA to checkout. Defaults to the repository's default branch."
required: false
type: string
workflow_call:
inputs:
checkout-path:
description: "Path to check out code to"
required: false
type: string
skip-relevance-check:
description: "Bypass relevance check"
required: false
type: boolean
default: false
pr-base-sha:
description: "Base SHA of the PR for relevance check"
required: false
type: string
pr-head-sha:
description: "Head SHA of the PR for relevance check"
required: false
type: string
ref:
description: "The branch, ref, or SHA to checkout"
required: false
type: string
repo:
description: "The repository to checkout from"
required: false
type: string
jobs:
setup:
runs-on: ubuntu-latest
outputs:
is_act: ${{ steps.setup.outputs.is_act }}
ref: ${{ steps.setup.outputs.ref }}
repo: ${{ steps.setup.outputs.repo }}
base_sha: ${{ steps.setup.outputs.base_sha }}
pr_number: ${{ steps.setup.outputs.pr_number }}
checkout_path: ${{ steps.setup.outputs.checkout_path }}
has_changes: ${{ steps.setup.outputs.has_changes }}
steps:
- name: Workflow setup
id: setup
uses: Framework-R-D/phlex/.github/actions/workflow-setup@main
with:
file-type: md
head-ref: ${{ inputs.pr-head-sha }}
ref: ${{ inputs.ref }}
repo: ${{ inputs.repo }}
pr-base-sha: ${{ inputs.pr-base-sha }}
checkout-path: ${{ inputs.checkout-path }}
markdown-check:
needs: setup
if: >
always() && (
github.event_name == 'workflow_dispatch' ||
inputs.skip-relevance-check ||
needs.setup.outputs.has_changes == 'true'
)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ needs.setup.outputs.ref }}
path: ${{ needs.setup.outputs.checkout_path }}
repository: ${{ needs.setup.outputs.repo }}
persist-credentials: false
- name: Add problem matcher
uses: xt0rted/markdownlint-problem-matcher@1a5fabfb577370cfdf5af944d418e4be3ea06f27 # v3.0.0
- name: Run markdownlint
id: lint
uses: DavidAnson/markdownlint-cli2-action@07035fd053f7be764496c0f8d8f9f41f98305101 # v22.0.0
with:
globs: |
${{ needs.setup.outputs.checkout_path }}/**/*.md
!${{ needs.setup.outputs.checkout_path }}/**/CHANGELOG.md
continue-on-error: true
- name: Evaluate markdownlint result
if: always() && steps.lint.outcome != 'skipped'
env:
REPO: ${{ needs.setup.outputs.repo }}
# yamllint disable rule:line-length
run: |
REPO_NAME="${REPO##*/}"
if [ "${{ steps.lint.outcome }}" = "success" ]; then
echo "✅ Markdown formatting check passed."
else
echo "::error::Markdown formatting check failed."
echo "::error::Comment '@${REPO_NAME}bot format' or '@${REPO_NAME}bot markdown-fix' on the PR to auto-fix."
exit 1
fi
# yamllint enable