Skip to content

Commit 1b7772f

Browse files
committed
[PRM-537] Introduce markdown validation on PRs
1 parent 631f905 commit 1b7772f

File tree

2 files changed

+55
-13
lines changed

2 files changed

+55
-13
lines changed

.github/workflows/automated-sbom-repo-scan.yml renamed to .github/workflows/automated-pr-checks.yml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
name: 'Z-AUTOMATED: SBOM Repo Scan'
1+
name: "Z-AUTOMATED: PR Checks"
22

33
on:
44
pull_request:
55
types: [opened, synchronize, reopened]
66

7-
permissions:
8-
actions: read # Required for anchore/sbom-action
9-
contents: write # Required for anchore/sbom-action
10-
id-token: write # Required for requesting the JWT
11-
pull-requests: write
12-
137
jobs:
148
sbom_scan:
159
name: SBOM Repo Scan
1610
runs-on: ubuntu-latest
11+
permissions:
12+
actions: read # Required for anchore/sbom-action
13+
contents: write # Required for anchore/sbom-action
14+
id-token: write # Required for requesting the JWT
15+
pull-requests: write
1716
steps:
18-
- uses: actions/checkout@v5
17+
- name: Checkout
18+
uses: actions/checkout@v5
1919
with:
20-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
20+
fetch-depth: 0
2121

2222
- uses: anchore/sbom-action@v0
2323
with:
@@ -51,14 +51,14 @@ jobs:
5151
repo: context.repo.repo,
5252
issue_number: context.issue.number,
5353
})
54-
54+
5555
const botComment = comments.find(comment => {
5656
return comment.user.type === 'Bot' && comment.body.includes('Code security issues found')
5757
})
5858
5959
// 2. Prepare format of the comment
6060
const output = `### Code security issues found
61-
61+
6262
View full details [here](https://github.com/${{ github.repository }}/security/code-scanning?query=is%3Aopen+pr%3A${{ github.event.pull_request.number }}).`;
6363
6464
// 3. If we have a comment, update it, otherwise create a new one
@@ -70,7 +70,7 @@ jobs:
7070
body: output
7171
})
7272
}
73-
73+
7474
github.rest.issues.createComment({
7575
issue_number: context.issue.number,
7676
owner: context.repo.owner,
@@ -89,7 +89,7 @@ jobs:
8989
repo: context.repo.repo,
9090
issue_number: context.issue.number,
9191
})
92-
92+
9393
const botComment = comments.find(comment => {
9494
return comment.user.type === 'Bot' && comment.body.includes('Code security issues found')
9595
})
@@ -102,3 +102,21 @@ jobs:
102102
comment_id: botComment.id
103103
})
104104
}
105+
106+
markdown-validator:
107+
name: Markdown Validator
108+
runs-on: ubuntu-latest
109+
permissions:
110+
contents: read
111+
steps:
112+
- name: Checkout
113+
uses: actions/checkout@v6
114+
with:
115+
fetch-depth: 0
116+
117+
- name: Run Markdown Validator Script
118+
id: validate
119+
run: |
120+
BRANCH_NAME=${{ github.event.repository.default_branch }}
121+
chmod +x scripts/markdown-validator.sh
122+
scripts/markdown-validator.sh

scripts/markdown-validator.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# Check Markdown formating of all the "*.md" files that are changed and commited to the current branch.
4+
#
5+
# Usage:
6+
# $ [options] ./markdown-check-format.sh
7+
#
8+
# Options:
9+
# BRANCH_NAME=other-branch-than-main # Branch to compare with
10+
11+
# Please, make sure to enable Markdown linting in your IDE. For the Visual Studio Code editor it is
12+
# `davidanson.vscode-markdownlint` that is already specified in the `.vscode/extensions.json` file.
13+
14+
#files=$((git diff --diff-filter=ACMRT --name-only origin/${BRANCH_NAME:-main}.. "*.md"; git diff --name-only "*.md") | sort | uniq)
15+
files=$((find . -name "*.md" -printf '%P\n') | sort | uniq)
16+
17+
if [ -n "$files" ]; then
18+
image=ghcr.io/igorshubovych/markdownlint-cli@sha256:b771097d3d9ec6b368fefcea5f0c05c8710293d9251fca17e31c8e10987b50ef # v0.46.0
19+
docker run --rm \
20+
-v $PWD:/workdir \
21+
$image \
22+
$files \
23+
--disable MD013 MD033
24+
fi

0 commit comments

Comments
 (0)