-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yml
More file actions
63 lines (52 loc) · 1.63 KB
/
Copy pathaction.yml
File metadata and controls
63 lines (52 loc) · 1.63 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
name: 'md-babel-py'
description: 'Execute code blocks in markdown files'
author: 'Ivan Nikolic'
branding:
icon: 'file-text'
color: 'blue'
inputs:
files:
description: 'Markdown files to process (glob pattern or space-separated list)'
required: true
args:
description: 'Additional arguments to pass to md-babel-py'
required: false
default: ''
fail-on-change:
description: 'Fail if files were modified (useful for CI checks)'
required: false
default: 'false'
outputs:
changed-files:
description: 'List of files that were modified'
value: ${{ steps.run.outputs.changed }}
runs:
using: 'composite'
steps:
- name: Run md-babel-py
id: run
shell: bash
run: |
changed=""
# Expand globs and process each file
for pattern in ${{ inputs.files }}; do
for file in $pattern; do
[ -f "$file" ] || continue
echo "Processing: $file"
# Get hash before
hash_before=$(sha256sum "$file" | cut -d' ' -f1)
# Run md-babel-py
docker run --rm -v "$PWD":/work lesh/md-babel-py:main run "/work/$file" ${{ inputs.args }}
# Get hash after
hash_after=$(sha256sum "$file" | cut -d' ' -f1)
if [ "$hash_before" != "$hash_after" ]; then
echo " -> Modified"
changed="$changed $file"
fi
done
done
echo "changed=${changed# }" >> "$GITHUB_OUTPUT"
if [ "${{ inputs.fail-on-change }}" = "true" ] && [ -n "$changed" ]; then
echo "::error::Files were modified: $changed"
exit 1
fi