-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
80 lines (75 loc) · 2.84 KB
/
action.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
74
75
76
77
78
79
80
name: 'SourceMod Cvar Docs'
description: 'Automatic Markdown documentation for SourceMod plugin ConVars.'
author: 'https://github.com/Rainyan'
inputs:
cwd:
description: 'Current working directory.'
default: '${{ github.workspace }}'
code_patterns:
description: 'RegEx pattern for code files to match.'
default: '^.*\.(sp|inc|SP|INC)$'
doc_patterns:
description: 'RegEx pattern for documentation files to match.'
default: '^[Rr][Ee][Aa][Dd][Mm][Ee]\.[Mm][Dd]$'
header_patterns:
description: 'RegEx pattern for documentation headers to match for the location of the cvar docs placeholder.'
default: '([Cc]vars|[Cc]on[Vv]ars|[Cc]onsole [Vv]ariables)'
dry_run:
description: 'Whether to print the output to stdout instead of writing to file.'
default: false
encoding:
description: 'Encoding to use for file read/write operations.'
default: 'utf-8'
format_filename:
description: 'Formatting for the code file name, with placeholder $a. This is skipped if parsing one single code file.'
default: '### !a!\n'
format_cvarname:
description: 'Formatting for the cvar name, with placeholder $a.'
default: '* !a!\n'
format_cvarprop:
description: 'Formatting for the cvar property, with placeholder $a (property name), and $b (property default value).'
default: ' * !a!: `!b!`\n'
runs:
using: 'composite'
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Add action path
run: echo "${{ github.action_path }}" >> $GITHUB_PATH
shell: bash
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade -r "${{ github.action_path }}/requirements.txt"
- name: Update documentation files
shell: bash
run: |
if ${{ inputs.dry_run }}; then
dryrunarg="--dry-run"
fi
python '${{ github.action_path }}/document.py' \
'${{ inputs.cwd }}' \
-C '${{ inputs.code_patterns }}' \
-D '${{ inputs.doc_patterns }}' \
-H '${{ inputs.header_patterns }}' \
--encoding '${{ inputs.encoding }}' \
--format-filename '${{ inputs.format_filename }}' \
--format-cvarname '${{ inputs.format_cvarname }}' \
--format-cvarprop '${{ inputs.format_cvarprop }}' \
$dryrunarg
- name: Pull Remote Changes
shell: bash
run: git pull
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && github.event_name == 'pull_request'
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update cvars documentation
file_pattern: '*.md'
# Branding reference: https://haya14busa.github.io/github-action-brandings/
branding:
icon: 'book-open'
color: 'green'