-
Notifications
You must be signed in to change notification settings - Fork 1
200 lines (197 loc) · 7.09 KB
/
markdown.yaml
File metadata and controls
200 lines (197 loc) · 7.09 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# Copyright 2024 Zaphiro Technologies
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Base Lint
concurrency:
group: ${{ github.ref_name }}-base-lint
cancel-in-progress: true
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
# Replace pull_request with pull_request_target if you
# plan to use this action with forks, see the Limitations section
pull_request:
branches:
- main
types: [opened, reopened, ready_for_review, synchronize]
workflow_call:
inputs:
config-links-path:
required: false
default: ".github/config/.linkspector.yml"
type: string
config-lint-path:
default: ".github/config/.markdownlint.json"
required: false
type: string
md-lint-globs:
required: false
type: string
default: |
**/*.md
**/*.MD
#.github
#vendor
#RELEASE_NOTES.md
jobs:
changes:
if: ${{ github.event.pull_request.draft == false }}
runs-on: ubuntu-latest
outputs:
files_changed: ${{ steps.filter.outputs.markdown == 'true' || steps.filter.outputs.scripts == 'true' }}
markdown_files: ${{ steps.filter.outputs.markdown_files }}
github_actions_files_changed: ${{ steps.filter.outputs.github-actions == 'true' }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2 # To retrieve the preceding commit.
- uses: dorny/paths-filter@v4
id: filter
with:
list-files: shell
filters: |
scripts:
- '.github/config/.markdownlint.json'
- '.github/config/.prettierignore'
- '.github/config/.linkspector.yml'
- '.gramma.json'
- '.grammarignore'
- 'grammar-check.sh'
- '.github/workflows/markdown.yaml'
markdown:
- '**/!(*RELEASE_NOTES).(md|MD)'
github-actions:
- '.github/workflows/*.(yaml|yml)'
github-actions:
needs: changes
if: ${{ needs.changes.outputs.github_actions_files_changed == 'true' && github.event.pull_request.draft == false }}
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v3
id: generate-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_SECRET }}
permission-contents: write
permission-workflows: write
- uses: actions/checkout@v6
with:
token: ${{ steps.generate-token.outputs.token }}
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Prettify YAML files
uses: creyD/prettier_action@v4.6
with:
prettier_options: --write "**/*.{yml,yaml}" --ignore-path .github/config/.prettierignore
dry: true
no_commit: true
- name: Commit yaml-lint changes
run: |
git config --global user.name 'Bot'
git config --global user.email 'bot@zaphiro.ch'
git commit -am "Automated yaml-lint fixes [dependabot skip]" || echo "No changes to commit"
git push
- uses: reviewdog/action-actionlint@v1
env:
# https://www.shellcheck.net/wiki/
SHELLCHECK_OPTS: "-e SC2086 -e SC2129"
with:
level: warning
fail_level: error
reporter: github-pr-review
markdown:
needs: changes
if: ${{ needs.changes.outputs.files_changed == 'true' && github.event.pull_request.draft == false }}
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v3
id: generate-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_SECRET }}
permission-contents: write
- uses: actions/checkout@v6
with:
token: ${{ steps.generate-token.outputs.token }}
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Prettify MD files
uses: creyD/prettier_action@v4.6
with:
prettier_options: --prose-wrap always --write **/*.{md,MD} --ignore-path .github/config/.prettierignore
dry: true
no_commit: true
- name: Lint
uses: DavidAnson/markdownlint-cli2-action@v23
with:
fix: true
config: ${{ inputs.config-lint-path || '.github/config/.markdownlint.json' }}
globs: ${{ inputs.md-lint-globs || '**/*.md,**/*.MD,#__tests__/test.md' }}
separator: ${{ inputs.md-lint-globs && '' || ',' }}
- name: Commit markdown-lint changes
run: |
git config --global user.name 'Bot'
git config --global user.email 'bot@zaphiro.ch'
git commit -am "Automated markdown-lint fixes [dependabot skip]" || echo "No changes to commit"
git push
- name: Fix apparmor issue for puppeteer
run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
- name: Default configuration for link checker
run: |
FILE=${{ inputs.config-links-path || '.github/config/.linkspector.yml' }}
if [ -f $FILE ]; then
echo "'$FILE' Exists"
else
# Write content to the file
cat <<EOF > "$FILE"
dirs:
- .
excludedDirs:
- vendor
useGitIgnore: true
aliveStatusCodes:
- 200
- 201
- 204
- 206
- 429
ignorePatterns:
- pattern: '^http(s?)://localhost'
- pattern: '^https://github.com/orgs/zaphiro-technologies/'
- pattern: '^https://github.com/zaphiro-technologies/'
EOF
fi
- name: Enable Corepack for modern package managers
run: |
corepack enable
- name: Prepare Yarn cache path for setup-node
shell: bash
run: |
if [ -f package.json ] && grep -Eq '"packageManager"\s*:\s*"yarn@' package.json; then
CACHE_DIR=$(yarn config get cacheFolder | tr -d '"')
mkdir -p "$CACHE_DIR"
echo "Prepared Yarn cache directory: $CACHE_DIR"
fi
- name: Prepare reviewdog cache path
run: |
mkdir -p "$HOME/reviewdog-bin"
- name: Check links
uses: umbrelladocs/action-linkspector@v1
with:
filter_mode: nofilter
reporter: github-pr-review
config_file: ${{ inputs.config-links-path || '.github/config/.linkspector.yml' }}
fail_level: any