Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mk 2 #78

Closed
wants to merge 3 commits into from
Closed

Mk 2 #78

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/markdown-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: 'Markdown linter'
on:
pull_request:
branches:
- main
paths:
- '**.md'
# Remove all permissions by default
permissions: {}
jobs:
markdown-linter:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Install mardownlint
run: npm install -g markdownlint-cli@0.33.0
- name: Checkout project
uses: actions/checkout@v3
- name: Execute markdownlint
env:
DIFF_URL: "${{github.event.pull_request.diff_url}}"
TEMP_FILE: "${{runner.temp}}/pr-${{github.event.number}}.diff"
run: |
# This request doesn't consume API calls.
curl -Lkso $TEMP_FILE $DIFF_URL
files_changed="$(sed -nr 's/[\-\+]{3} [ab]\/(.*)/\1/p' $TEMP_FILE | sort | uniq)"
md_files="$(echo "$files_changed" | grep -o ".*\.md$" | sort | uniq || true)"
# Create an empty file, useful when the PR changes ignored files
touch ${{runner.temp}}/output
exit_code=0
markdownlint -o ${{runner.temp}}/output ${md_files[@]} || exit_code=$?
while read -r line; do
# line format:
# file:row[:column] message
# white space inside brackets is intentional to detect the message for the notice.
message="${line#*[ ]}"
file_row_column="${line%%[ ]*}"
# Split by ':'
readarray -d : -t strarr < <(printf '%s' "$file_row_column")
echo "${#strarr[@]}"
if [[ "${#strarr[@]}" -eq 3 ]]; then
echo "::warning file=${strarr[0]},line=${strarr[1]},col=${strarr[2]}::${message}"
elif [[ "${#strarr[@]}" -eq 2 ]]; then
echo "::warning file=${strarr[0]},line=${strarr[1]}::${message}"
else
echo "::warning:: Error processing: ${line}"
fi
done < ${{runner.temp}}/output
if [[ $exit_code -ne 0 ]]; then
echo "::error:: Please review linter messages"
exit "$exit_code"
fi
2 changes: 1 addition & 1 deletion charts/timesketch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## TL;DR

```console
```

Check warning on line 12 in charts/timesketch/README.md

View workflow job for this annotation

GitHub Actions / markdown-linter

MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
helm install my-release oci://us-docker.pkg.dev/osdfir-registry/osdfir-charts/timesketch
```

Expand Down
Loading