-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaction.yml
190 lines (182 loc) · 6.31 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
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
name: rich-codex
author: Phil Ewels
description: Create rich code images for your docs
branding:
icon: "terminal"
color: "blue"
inputs:
search_include:
description: Glob patterns to files in which to search for rich-codex comments
required: false
search_exclude:
description: Glob patterns to exclude from search for rich-codex comments
required: false
no_search:
description: Set to 'true' to disable searching for rich-codex comments
required: false
command:
description: Specify a command to run to capture output
required: false
timeout:
description: Maximum run time for command (seconds)
required: false
before_command:
description: Setup commands to run before running main output command
required: false
after_command:
description: Setup commands to run after running main output command
required: false
snippet:
description: Literal code snippet to render
required: false
snippet_syntax:
description: Language to use for snippet sytax highlighting
required: false
img_paths:
description: Path to image filenames if using 'command' or 'snippet'
required: false
clean_img_paths:
description: Remove any matching files that are not generated
required: false
rc_configs:
description: Paths to YAML config files
required: false
fake_command:
description: Pretend command to show in the screenshot prompt
required: false
hide_command:
description: Hide the terminal prompt with the command at the top of the output
required: false
title_command:
description: Use the command as the terminal title if not set explicitly
required: false
head:
description: Show only the first N lines of output
required: false
tail:
description: Show only the last N lines of output
required: false
trim_after:
description: Don't print any more lines after this string is found
required: false
truncated_text:
description: Text to show when '--head' or '--tail' truncate content
required: false
skip_git_checks:
description: Skip safety checks for git repos
required: false
min_pct_diff:
description: Minimum file percentage change required to update image
required: false
skip_change_regex:
description: Skip image update if file changes match regex
required: false
terminal_width:
description: Width of the terminal
required: false
terminal_min_width:
description: Minimum width of the terminal (use trimming)
required: false
notrim:
description: Disable automatic trimming of terminal width
required: false
terminal_theme:
description: Colour theme
required: false
snippet_theme:
description: Snippet Pygments theme
required: false
use_pty:
description: Use a pseudo-terminal for commands (may capture coloured output)
required: false
log_verbose:
description: Print verbose output to the console.
required: false
commit_changes:
description: Automatically commit changes to the repository
required: false
error_changes:
description: Exit with an error if changes are found (Ignored if 'commit_changes' is true)
default: "true"
required: false
runs:
using: "composite"
steps:
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.x
- name: Install rich-codex
run: |
echo "::group::Installing rich-codex"
sudo apt install fonts-firacode
pip install "rich-codex[cairo]"
echo "::endgroup::"
shell: bash
- name: Run rich-codex
run: rich-codex
shell: bash
env:
SEARCH_INCLUDE: ${{ inputs.search_include }}
SEARCH_EXCLUDE: ${{ inputs.search_exclude }}
NO_SEARCH: ${{ inputs.no_search }}
COMMAND: ${{ inputs.command }}
TIMEOUT: ${{ inputs.timeout }}
BEFORE_COMMAND: ${{ inputs.before_command }}
AFTER_COMMAND: ${{ inputs.after_command }}
SNIPPET: ${{ inputs.snippet }}
SNIPPET_SYNTAX: ${{ inputs.snippet_syntax }}
IMG_PATHS: ${{ inputs.img_paths }}
CLEAN_IMG_PATHS: ${{ inputs.clean_img_paths }}
RC_CONFIGS: ${{ inputs.rc_configs }}
FAKE_COMMAND: ${{ inputs.fake_command }}
HIDE_COMMAND: ${{ inputs.hide_command }}
TITLE_COMMAND: ${{ inputs.title_command }}
RC_HEAD: ${{ inputs.head }}
RC_TAIL: ${{ inputs.tail }}
TRIM_AFTER: ${{ inputs.trim_after }}
TRUNCATED_TEXT: ${{ inputs.truncated_text }}
SKIP_GIT_CHECKS: ${{ inputs.skip_git_checks }}
MIN_PCT_DIFF: ${{ inputs.min_pct_diff }}
SKIP_CHANGE_REGEX: ${{ inputs.skip_change_regex }}
TERMINAL_WIDTH: ${{ inputs.terminal_width }}
TERMINAL_MIN_WIDTH: ${{ inputs.terminal_min_width }}
NOTRIM: ${{ inputs.notrim }}
TERMINAL_THEME: ${{ inputs.terminal_theme }}
SNIPPET_THEME: ${{ inputs.snippet_theme }}
USE_PTY: ${{ inputs.use_pty }}
CREATED_FILES: "created.txt"
DELETED_FILES: "deleted.txt"
LOG_VERBOSE: ${{ inputs.log_verbose }}
LOG_SAVE: "true"
NO_CONFIRM: "true"
- name: Add and commit new images
shell: bash
run: |
echo "::group::Pushing any changes found"
git config --local user.name 'github-actions[bot]'
git config --local user.email 'github-actions[bot]@users.noreply.github.com'
echo "🕵️♀️ Git status after run:"
git status -s
if [[ -f created.txt || -f deleted.txt ]]; then
echo "💥 Found some changes from running rich-codex!"
if [[ ${{ inputs.commit_changes }} ]]; then
[[ -f created.txt ]] && git add $(cat created.txt)
[[ -f deleted.txt ]] && git rm $(cat deleted.txt)
git commit -m "Generate new screengrabs with rich-codex"
git push
echo "🤖 Pushed commit with new changes!"
elif [[ ${{ inputs.error_changes }} ]]; then
echo "🤖 Tip: Use 'commit_changes' to automatically commit them next time."
(exit 1)
fi
else
echo "🤫 No changes from rich-codex found!"
fi
echo "::endgroup::"
- name: Upload sync log file artifact
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: Rich-codex log file
path: rich_codex_*.log