-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
219 lines (199 loc) · 7.38 KB
/
action.yml
File metadata and controls
219 lines (199 loc) · 7.38 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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: Setup Skillshare
description: Install and initialize skillshare CLI for managing AI coding skills
author: runkids
branding:
icon: package
color: blue
inputs:
version:
description: "Skillshare version to install (without v prefix). Defaults to latest."
required: false
default: "latest"
source:
description: "Path to skills source directory (passed to --source)."
required: false
targets:
description: "Comma-separated target names (e.g. claude,cursor). Defaults to all detected."
required: false
mode:
description: "Sync mode: merge, copy, or symlink."
required: false
git:
description: "Initialize git in source directory. Set to 'true' to enable."
required: false
default: "false"
remote:
description: "Git remote URL for cross-machine sync (implies git: true)."
required: false
project:
description: "Use project-level skills (.skillshare/ in current directory)."
required: false
default: "false"
audit:
description: "Run security audit after setup. Set to 'true' to enable."
required: false
default: "false"
audit-threshold:
description: "Audit severity threshold: critical, high, medium, low, info (or c, h, m, l, i)."
required: false
default: "high"
audit-format:
description: "Audit output format: text, json, sarif, markdown."
required: false
default: "text"
audit-profile:
description: "Audit profile preset: default, strict, permissive."
required: false
audit-output:
description: "File path to save audit results (e.g. skillshare-audit.sarif)."
required: false
github-token:
description: "GitHub token for API requests to avoid rate limits."
required: false
default: ${{ github.token }}
outputs:
version:
description: "The installed skillshare version"
value: ${{ steps.version.outputs.version }}
audit-exit-code:
description: "Audit exit code (0 = clean, 1 = findings)"
value: ${{ steps.audit.outputs.exit-code }}
runs:
using: composite
steps:
- name: Detect platform
id: platform
shell: bash
run: |
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$ARCH" in
x86_64|amd64) ARCH="amd64" ;;
arm64|aarch64) ARCH="arm64" ;;
*) echo "::error::Unsupported architecture: $ARCH"; exit 1 ;;
esac
echo "os=$OS" >> "$GITHUB_OUTPUT"
echo "arch=$ARCH" >> "$GITHUB_OUTPUT"
- name: Resolve version
id: version
shell: bash
env:
GH_TOKEN: ${{ inputs.github-token }}
INPUT_VERSION: ${{ inputs.version }}
run: |
if [ "$INPUT_VERSION" = "latest" ]; then
# Primary: curl HTTP redirect (no gh CLI needed)
VERSION=$(curl -sI "https://github.com/runkids/skillshare/releases/latest" \
| grep -i "^location:" | sed 's/.*tag\/v\([^[:space:]]*\).*/\1/' | tr -d '\r')
# Fallback: gh API (if curl redirect fails and gh is available)
if [ -z "$VERSION" ] && command -v gh &>/dev/null; then
VERSION=$(gh api repos/runkids/skillshare/releases/latest --jq '.tag_name' | sed 's/^v//')
fi
if [ -z "$VERSION" ]; then
echo "::error::Failed to resolve latest version"
exit 1
fi
else
VERSION="$INPUT_VERSION"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Resolved skillshare version: $VERSION"
- name: Install skillshare
shell: bash
env:
VERSION: ${{ steps.version.outputs.version }}
OS: ${{ steps.platform.outputs.os }}
ARCH: ${{ steps.platform.outputs.arch }}
run: |
INSTALL_DIR="$RUNNER_TOOL_CACHE/skillshare/${VERSION}"
# Skip download if already cached from a previous step/job in this run
if [ -x "$INSTALL_DIR/skillshare" ]; then
echo "skillshare ${VERSION} already cached at $INSTALL_DIR, skipping download"
echo "$INSTALL_DIR" >> "$GITHUB_PATH"
exit 0
fi
URL="https://github.com/runkids/skillshare/releases/download/v${VERSION}/skillshare_${VERSION}_${OS}_${ARCH}.tar.gz"
mkdir -p "$INSTALL_DIR"
echo "Downloading skillshare ${VERSION} for ${OS}/${ARCH}..."
curl --retry 3 --retry-delay 1 -fsSL "$URL" | tar xz -C "$INSTALL_DIR"
chmod +x "$INSTALL_DIR/skillshare"
echo "$INSTALL_DIR" >> "$GITHUB_PATH"
- name: Initialize skillshare
shell: bash
env:
INPUT_SOURCE: ${{ inputs.source }}
INPUT_TARGETS: ${{ inputs.targets }}
INPUT_MODE: ${{ inputs.mode }}
INPUT_GIT: ${{ inputs.git }}
INPUT_REMOTE: ${{ inputs.remote }}
INPUT_PROJECT: ${{ inputs.project }}
run: |
if [ "$INPUT_PROJECT" = "true" ]; then
# Project mode: init -p only accepts --targets, --mode
INIT_ARGS="-p"
if [ -n "$INPUT_TARGETS" ]; then
INIT_ARGS="$INIT_ARGS --targets $INPUT_TARGETS"
fi
[ -n "$INPUT_MODE" ] && INIT_ARGS="$INIT_ARGS --mode $INPUT_MODE"
else
# Global mode
INIT_ARGS="--no-copy --no-skill"
if [ -n "$INPUT_SOURCE" ] && [ ! -d "$INPUT_SOURCE" ]; then
echo "::error::Source directory not found: $INPUT_SOURCE"
exit 1
fi
[ -n "$INPUT_SOURCE" ] && INIT_ARGS="$INIT_ARGS --source $INPUT_SOURCE"
if [ -n "$INPUT_TARGETS" ]; then
INIT_ARGS="$INIT_ARGS --targets $INPUT_TARGETS"
else
INIT_ARGS="$INIT_ARGS --all-targets"
fi
[ -n "$INPUT_MODE" ] && INIT_ARGS="$INIT_ARGS --mode $INPUT_MODE"
if [ -n "$INPUT_REMOTE" ]; then
INIT_ARGS="$INIT_ARGS --remote $INPUT_REMOTE"
elif [ "$INPUT_GIT" = "true" ]; then
INIT_ARGS="$INIT_ARGS --git"
else
INIT_ARGS="$INIT_ARGS --no-git"
fi
fi
echo "Running: skillshare init $INIT_ARGS"
skillshare init $INIT_ARGS
- name: Verify installation
shell: bash
run: skillshare version
- name: Run security audit
id: audit
if: inputs.audit == 'true'
shell: bash
env:
INPUT_AUDIT_THRESHOLD: ${{ inputs.audit-threshold }}
INPUT_AUDIT_FORMAT: ${{ inputs.audit-format }}
INPUT_AUDIT_PROFILE: ${{ inputs.audit-profile }}
INPUT_AUDIT_OUTPUT: ${{ inputs.audit-output }}
INPUT_PROJECT: ${{ inputs.project }}
run: |
AUDIT_ARGS="--threshold $INPUT_AUDIT_THRESHOLD --format $INPUT_AUDIT_FORMAT --yes --no-tui"
# --project
[ "$INPUT_PROJECT" = "true" ] && AUDIT_ARGS="$AUDIT_ARGS -p"
if [ -n "$INPUT_AUDIT_PROFILE" ]; then
AUDIT_ARGS="$AUDIT_ARGS --profile $INPUT_AUDIT_PROFILE"
fi
echo "Running: skillshare audit $AUDIT_ARGS"
if [ -n "$INPUT_AUDIT_OUTPUT" ]; then
# Save to file; capture exit code for output (let downstream decide)
set +e
skillshare audit $AUDIT_ARGS > "$INPUT_AUDIT_OUTPUT"
EXIT_CODE=$?
set -e
echo "exit-code=$EXIT_CODE" >> "$GITHUB_OUTPUT"
echo "Audit results saved to $INPUT_AUDIT_OUTPUT"
else
# No output file — propagate exit code directly
set +e
skillshare audit $AUDIT_ARGS
EXIT_CODE=$?
set -e
echo "exit-code=$EXIT_CODE" >> "$GITHUB_OUTPUT"
exit $EXIT_CODE
fi