Skip to content

greenc-FNAL checking YAML files #336

greenc-FNAL checking YAML files

greenc-FNAL checking YAML files #336

Workflow file for this run

name: YAML Check
"run-name": "${{ github.actor }} checking YAML files"
permissions:
contents: 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
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: yaml
yaml-check:
needs: setup
if: >
always() && (github.event_name == 'workflow_dispatch' || needs.setup.outputs.has_changes == 'true')
runs-on: ubuntu-latest
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: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.x"
- name: Install yamllint
run: pip install yamllint
- name: Run yamllint
id: lint
working-directory: ${{ needs.setup.outputs.checkout_path }}
run: yamllint .
continue-on-error: true
- name: Evaluate yamllint result
if: always() && steps.lint.outcome != 'skipped'
env:
REPO: ${{ needs.setup.outputs.repo }}
run: |
REPO_NAME="${REPO##*/}"
if [ "${{ steps.lint.outcome }}" = "success" ]; then
echo "✅ YAML check passed."
else
echo "::error::YAML check failed."
echo "::error::Comment '@${REPO_NAME}bot yaml-fix' on the PR to auto-fix."
exit 1
fi