generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 102
73 lines (71 loc) · 2.77 KB
/
lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Lint
on:
pull_request:
branches: [main]
paths:
- '**.md'
workflow_dispatch:
jobs:
suggestions:
runs-on: ubuntu-latest
if: '! github.event.pull_request.head.repo.fork'
permissions:
pull-requests: write
steps:
- name: Checkout SAP repo
run: |
git config --global credential.helper "cache --timeout=3600"
echo -e "url=https://user:${GH_TOKEN}@github.com\n" | git credential approve
echo -e "url=https://user:${GH_TOKEN_PARENT}@github.tools.sap\n" | git credential approve
git clone --depth 1 --no-single-branch https://github.tools.sap/cap/docs docs
cd docs
git checkout $GITHUB_HEAD_REF || git checkout main
git submodule update --init --recursive
cd @external
git checkout $GITHUB_HEAD_REF
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN_PARENT: ${{ secrets.GH_TOKEN_PARENT }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'
cache-dependency-path: docs/package-lock.json
- run: npm ci
working-directory: docs
- run: git checkout ${{ github.head_ref }}
working-directory: docs/@external
- name: Get changes
id: changes
working-directory: docs/@external
run: |
echo "DIFF_FILES=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- '*.md' | xargs)" >> "$GITHUB_OUTPUT"
- name: Run cspell
id: cspell
continue-on-error: true
working-directory: docs/@external
run: |
npx cspell --no-progress --show-suggestions --show-context ${{ steps.changes.outputs.DIFF_FILES }} >> ${{ github.workspace }}/docs/@external/CSPELL.log
- name: Run markdownlint
id: markdownlint
continue-on-error: true
working-directory: docs/@external
run: |
npx markdownlint-cli --output ${{ github.workspace }}/docs/@external/MARKDOWNLINT.log -r markdownlint-rule-search-replace ${{ steps.changes.outputs.DIFF_FILES }}
- name: Create review
id: create_review
if: steps.cspell.outcome == 'failure' || steps.markdownlint.outcome == 'failure'
uses: actions/github-script@v6
env:
SHA: ${{ github.event.pull_request.head.sha }}
BASE_DIR: ${{ github.workspace }}/docs/@external
BASE_SHA: ${{ github.event.pull_request.base.sha }}
PULL_NUMBER: ${{ github.event.number }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
REPO: 'docs'
REPO_OWNER: 'cap-js'
with:
script: |
const script = require('${{ github.workspace }}/docs/@external/.github/etc/create-review.cjs')
await script({github, context, core, require, exec})