-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
74 lines (63 loc) · 2.82 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
name: ai-digest action
description: 'Runs ai-digest CLI as a GitHub Action'
inputs:
input_path:
description: 'The input directory to aggregate content from (default: current directory)'
required: false
default: '.'
output_file:
description: 'Specify output file (default: codebase.md)'
required: false
default: 'codebase.md'
digest_log:
description: 'Specify digest log file (default: ingest.md)'
required: false
default: 'ingest.md'
ai_digest_flags:
description: 'Flags passed to ai-digest, defaults to removing whitespace and displaying the output files in the digest log'
required: false
default: '--whitespace-removal --show-output-files'
outputs:
total_files:
description: Total number of files parsed from the `input_path` folder
value: ${{ steps.digest_stats.outputs.total_files }}
included_files:
description: Total number of files included in the output file
value: ${{ steps.digest_stats.outputs.included_files }}
ignored_files:
description: Total number of files ignored
value: ${{ steps.digest_stats.outputs.ignored_files }}
binary_files:
description: Total number of binary files in the output file
value: ${{ steps.digest_stats.outputs.binary_files }}
estimated_tokens:
description: Estimated number of tokens in the output file
value: ${{ steps.digest_stats.outputs.estimated_tokens }}
runs:
using: composite
steps:
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Run ai-digest
id: run_ai_digest
run: |
echo `Running ai-digest -i ${{ inputs.input_path }} ${{ inputs.ai_digest_flags }} -o ${{ inputs.output_file }}`
npx ai-digest -i ${{ inputs.input_path }} ${{ inputs.ai_digest_flags }} -o ${{ inputs.output_file }} | tee ${{ inputs.digest_log }}
echo "Created output file: ${{ inputs.output_file }}"
echo "Created digest log: ${{ inputs.digest_log }}"
shell: bash
- name: Extract ai-digest stats
id: digest_stats
run: |
echo "total_files=$(grep "Total files found" $DIGEST_LOG | cut -d":" -f2 | tr -d ' ')" >> $GITHUB_OUTPUT
echo "included_files=$(grep "Files included in output" $DIGEST_LOG | cut -d":" -f2 | tr -d ' ')" >> $GITHUB_OUTPUT
echo "ignored_files=$(grep "Files ignored by default patterns" $DIGEST_LOG | cut -d":" -f2 | tr -d ' ')" >> $GITHUB_OUTPUT
echo "binary_files=$(grep "Binary and SVG files included" $DIGEST_LOG | cut -d":" -f2 | tr -d ' ')" >> $GITHUB_OUTPUT
echo "estimated_tokens=$(grep "Estimated token count" $DIGEST_LOG | cut -d":" -f2 | tr -d ' ' | tr -d '⚠️')" >> $GITHUB_OUTPUT
shell: bash
env:
DIGEST_LOG: ${{ inputs.digest_log }}
branding:
icon: 'box'
color: 'gray-dark'