-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
71 lines (66 loc) · 2.48 KB
/
action.yml
File metadata and controls
71 lines (66 loc) · 2.48 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
name: Stacklit Index
description: Keep your AI-agent codebase index (stacklit.json + DEPENDENCIES.md) up to date automatically.
inputs:
mode:
description: "'auto-commit' to commit changes, 'check' to fail if index is stale"
required: false
default: auto-commit
version:
description: Stacklit version to install (e.g. v0.3.0 or latest)
required: false
default: latest
args:
description: Extra arguments to pass to stacklit generate
required: false
default: ""
runs:
using: composite
steps:
- name: Install Stacklit
shell: bash
run: |
set -euo pipefail
VERSION="${{ inputs.version }}"
if [ "$VERSION" = "latest" ]; then
VERSION=$(curl -fsSL https://api.github.com/repos/glincker/stacklit/releases/latest | grep '"tag_name"' | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
fi
if [ -z "$VERSION" ]; then
echo "::error::Failed to resolve Stacklit version"
exit 1
fi
echo "Installing stacklit $VERSION"
VNUM="${VERSION#v}"
curl -fsSL "https://github.com/glincker/stacklit/releases/download/${VERSION}/stacklit_${VNUM}_linux_amd64.tar.gz" -o /tmp/stacklit.tar.gz
tar -xzf /tmp/stacklit.tar.gz -C /usr/local/bin stacklit
chmod +x /usr/local/bin/stacklit
stacklit --version
- name: Run stacklit generate
shell: bash
run: |
set -euo pipefail
stacklit generate --quiet "${{ inputs.args }}"
- name: Check for index changes (check mode)
if: inputs.mode == 'check'
shell: bash
run: |
set -euo pipefail
if ! git diff --quiet -- stacklit.json DEPENDENCIES.md; then
echo "::error::stacklit index is stale. Run 'stacklit generate' and commit the changes."
git diff -- stacklit.json DEPENDENCIES.md
exit 1
fi
echo "stacklit index is up to date."
- name: Commit updated index (auto-commit mode)
if: inputs.mode == 'auto-commit'
shell: bash
run: |
set -euo pipefail
if git diff --quiet -- stacklit.json DEPENDENCIES.md; then
echo "No changes to stacklit index."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add stacklit.json DEPENDENCIES.md
git commit -m "chore: update stacklit index"
git push || { echo "::error::Failed to push stacklit index updates"; exit 1; }