Feature automate change-log #682
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .github/workflows/markdown-lint.yml | |
--- | |
name: Markdown Lint | |
on: # yamllint disable-line rule:truthy | |
push: | |
branches: ["main", "master", "stable"] | |
pull_request: | |
branches: ["main", "master", "stable", "feature-*", "patch-*", "HOTFIX-*"] | |
permissions: {} # Setting default permissions to none for enhanced security | |
jobs: | |
markdown-lint: | |
permissions: | |
contents: read | |
statuses: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
persist-credentials: false | |
- name: Install Apt-Get Dependencies | |
run: | | |
sudo apt-get update || exit 1 | |
sudo apt-get install -y yamllint npm || : # handle error with detail below | |
print_error() { | |
local msg="$1" | |
local file_stub=".github/workflows/markdown-lint.yml" | |
local line_start="$2" | |
local line_end="$3" | |
printf "::error file=%s,line=%s,endLine=%s,title=VALIDATION_ERROR::ERROR %s\n" \ | |
"${file_stub}" "${line_start}" "${line_end}" "${msg}" | |
} | |
command -v npm >/dev/null || { print_error "npm installation failed." 26 27 ; exit 126; } | |
yamllint --version || { print_error "Yamllint installation failed." 26 27 ; exit 126; } | |
- name: Lint Workflow YAML | |
if: ${{ success() }} | |
env: | |
YAML_ARGS: "${{ vars.YAML_ARGS }}" | |
run: | | |
printf "Validating workflow with args: %s\n" "${YAML_ARGS}" | |
# shellcheck disable=SC2086 | |
yamllint ${YAML_ARGS} .github/workflows/markdown-lint.yml | |
- name: Lint YAML config for markdown | |
if: ${{ success() }} | |
env: | |
YAML_ARGS: "${{ vars.YAML_ARGS }}" | |
run: | | |
printf "Validating workflow with args: %s\n" "${YAML_ARGS}" | |
# shellcheck disable=SC2086 | |
yamllint ${YAML_ARGS} .markdownlint.yaml | |
- name: Install NPM Dependencies | |
if: ${{ success() }} | |
run: | | |
# npm install | |
ERR_MSG="NPM package installation failed" | |
ERR_LOC_1="file=.github/workflows/markdown-lint.yml,line=63,endLine=63" | |
ERR_LOC_2="file=package.json,line=2,endLine=4" | |
if ! NPM_ERROR=$(npm install 2>&1); then | |
for LOC in "${ERR_LOC_1}" "${ERR_LOC_2}"; do | |
printf "::error %s,title=INSTALL_ERROR::ERROR %s: %s\n" \ | |
"${LOC}" "${ERR_MSG}" "${NPM_ERROR}" | |
done | |
fi | |
- name: Lint Markdown Files with YAML config | |
if: ${{ success() }} | |
run: | | |
git ls-files --exclude-standard -z -- *.md **/*.md |\ | |
xargs -0 -I{} npm run lint:md -- "{}"; |