Skip to content

Commit 511a0b0

Browse files
chore: script to generate examples (#244)
This PR addresses issue #68. It introduces a script to automatically generate the example workflow files from the main workflow files. This will help to keep the workflows DRY and avoid duplication.
1 parent 2a77eb2 commit 511a0b0

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Before contributing, ensure you have:
6565
```sh
6666
npm run docs
6767
```
68+
- If you update workflow files in `/.gemini/workflows/`, run `./scripts/generate-examples.sh` to auto-generate the examples.
6869

6970
3. **Commit Your Changes**
7071
- Commit with a descriptive message following [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)

scripts/generate-examples.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
7+
8+
WORKFLOWS_DIR="${REPO_ROOT}/.github/workflows"
9+
EXAMPLES_DIR="${REPO_ROOT}/examples/workflows"
10+
11+
for workflow_file in "${WORKFLOWS_DIR}"/*.yml; do
12+
workflow_name="$(basename "${workflow_file}")"
13+
example_dir=""
14+
example_filename=""
15+
16+
# Add case for each file that should exist in /examples/
17+
case "${workflow_name}" in
18+
"gemini-invoke.yml")
19+
example_dir="${EXAMPLES_DIR}/gemini-assistant"
20+
example_filename="gemini-invoke.yml"
21+
;;
22+
"gemini-triage.yml")
23+
example_dir="${EXAMPLES_DIR}/issue-triage"
24+
example_filename="gemini-triage.yml"
25+
;;
26+
"gemini-scheduled-triage.yml")
27+
example_dir="${EXAMPLES_DIR}/issue-triage"
28+
example_filename="gemini-scheduled-triage.yml"
29+
;;
30+
"gemini-review.yml")
31+
example_dir="${EXAMPLES_DIR}/pr-review"
32+
example_filename="gemini-review.yml"
33+
;;
34+
*)
35+
echo "Skipping ${workflow_name}"
36+
continue
37+
;;
38+
esac
39+
40+
example_file="${example_dir}/${example_filename}"
41+
echo "Generating ${example_file}"
42+
43+
# Update lines that are different in the /examples/, such as the version of the action
44+
sed \
45+
-e "s|uses: 'google-github-actions/run-gemini-cli@main'|uses: 'google-github-actions/run-gemini-cli@v0'|g" \
46+
"${workflow_file}" > "${example_file}"
47+
done

0 commit comments

Comments
 (0)