-
Notifications
You must be signed in to change notification settings - Fork 11
Add quick setup script for gh-aw workflows #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
strawgate
merged 19 commits into
main
from
issue-140-quick-setup-script-28dc95ff6ee078e5
Feb 21, 2026
Merged
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
59948c4
Add quick setup script for gh-aw
github-actions[bot] 871288d
Update quick setup defaults and add continuous improvement option
github-actions[bot] 81d35de
Merge branch 'main' into issue-140-quick-setup-script-28dc95ff6ee078e5
strawgate 2e45295
Expand --continuous-improvement workflows, drop pr-ci-fixer (#180)
Copilot 64218f3
Merge branch 'main' into issue-140-quick-setup-script-28dc95ff6ee078e5
strawgate c0c38f7
Add update-pr-body to quick-setup continuous improvement workflows (#…
Copilot 2400cdb
Merge branch 'main' into issue-140-quick-setup-script-28dc95ff6ee078e5
strawgate 0e1c127
Merge branch 'main' into issue-140-quick-setup-script-28dc95ff6ee078e5
strawgate 894bf5b
Fix branch ordering, token handling, and README
strawgate d5cfcbc
Clarify that COPILOT_GITHUB_TOKEN requires a classic PAT
strawgate 0da40c9
Use fine-grained PAT with copilot_requests permission
strawgate 927e1b5
Merge branch 'main' into issue-140-quick-setup-script-28dc95ff6ee078e5
strawgate 14c771a
Avoid exposing token in quick setup
github-actions[bot] e5b95e4
Merge branch 'main' into issue-140-quick-setup-script-28dc95ff6ee078e5
strawgate 7422d55
Base setup branch on default branch
github-actions[bot] 97b6473
Merge branch 'main' into issue-140-quick-setup-script-28dc95ff6ee078e5
strawgate e714a6e
Merge branch 'main' into issue-140-quick-setup-script-28dc95ff6ee078e5
strawgate 8000a09
Hide token input in quick setup
github-actions[bot] bc2078c
Merge branch 'main' into issue-140-quick-setup-script-28dc95ff6ee078e5
strawgate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,248 @@ | ||
| #!/usr/bin/env bash | ||
| # Quick setup for GitHub Agent Workflows in a repository. | ||
| # | ||
| # Usage: | ||
| # ./scripts/quick-setup.sh [--repo OWNER/REPO] [--branch NAME] | ||
| # [--workflows "pr-review,issue-triage,..."] | ||
| # [--skip-secret] [--dry-run] | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| branch="ai-gh-aw-setup" | ||
| repo="" | ||
| workflows_csv="" | ||
| skip_secret=false | ||
| continuous_improvement=false | ||
| dry_run=false | ||
|
|
||
| usage() { | ||
| cat <<'EOF' | ||
| Usage: quick-setup.sh [options] | ||
|
|
||
| Options: | ||
| --repo OWNER/REPO Repository to configure (defaults to current repo) | ||
| --branch NAME Branch name to create (default: ai-gh-aw-setup) | ||
| --workflows CSV Comma-separated workflow list (default: recommended set) | ||
| --skip-secret Skip setting COPILOT_GITHUB_TOKEN | ||
| --continuous-improvement | ||
| Add recommended continuous improvement workflows | ||
| --dry-run Print actions without making changes | ||
| -h, --help Show this help | ||
| EOF | ||
| } | ||
|
|
||
| while [ $# -gt 0 ]; do | ||
| case "$1" in | ||
| --repo) | ||
| repo="${2:-}" | ||
| shift 2 | ||
| ;; | ||
| --branch) | ||
| branch="${2:-}" | ||
| shift 2 | ||
| ;; | ||
| --workflows) | ||
| workflows_csv="${2:-}" | ||
| shift 2 | ||
| ;; | ||
| --skip-secret) | ||
| skip_secret=true | ||
| shift | ||
| ;; | ||
| --continuous-improvement) | ||
| continuous_improvement=true | ||
| shift | ||
| ;; | ||
| --dry-run) | ||
| dry_run=true | ||
| shift | ||
| ;; | ||
| -h|--help) | ||
| usage | ||
| exit 0 | ||
| ;; | ||
| *) | ||
| echo "Unknown flag: $1" >&2 | ||
| usage >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| require_cmd() { | ||
| if ! command -v "$1" >/dev/null 2>&1; then | ||
| echo "Missing required command: $1" >&2 | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| require_cmd gh | ||
| require_cmd git | ||
| require_cmd curl | ||
|
|
||
| repo_root="$(git rev-parse --show-toplevel 2>/dev/null || true)" | ||
| if [ -z "$repo_root" ]; then | ||
| echo "Run this script from inside a git repository." >&2 | ||
| exit 1 | ||
| fi | ||
| cd "$repo_root" | ||
|
|
||
| if [ -n "$(git status --porcelain)" ]; then | ||
| echo "Working tree has uncommitted changes. Commit or stash before running." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! gh auth status -h github.com >/dev/null 2>&1; then | ||
| echo "GitHub CLI is not authenticated. Run 'gh auth login' first." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "$repo" ]; then | ||
| repo="$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null || true)" | ||
| fi | ||
|
|
||
| if [ -z "$repo" ]; then | ||
| echo "Unable to determine repository. Use --repo OWNER/REPO." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "$branch" ]; then | ||
| echo "Branch name cannot be empty." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| base_url="https://raw.githubusercontent.com/elastic/ai-github-actions/v0" | ||
| default_workflows=( | ||
| pr-review | ||
| issue-triage | ||
| mention-in-issue | ||
| mention-in-pr | ||
| pr-ci-detective | ||
| ) | ||
| continuous_improvement_workflows=( | ||
| bug-hunter | ||
| bug-exterminator | ||
| code-simplifier | ||
| docs-drift | ||
| docs-new-contributor-review | ||
| small-problem-fixer | ||
| stale-issues | ||
| test-improvement | ||
| breaking-change-detect | ||
| semantic-function-clustering | ||
| ) | ||
|
|
||
| if [ -n "$workflows_csv" ]; then | ||
| workflows_csv="${workflows_csv// /}" | ||
| IFS=',' read -r -a workflows <<<"$workflows_csv" | ||
| else | ||
| workflows=("${default_workflows[@]}") | ||
| fi | ||
|
|
||
| append_workflow_if_missing() { | ||
| local candidate="$1" | ||
| local existing | ||
| for existing in "${workflows[@]}"; do | ||
| if [ "$existing" = "$candidate" ]; then | ||
| return | ||
| fi | ||
| done | ||
| workflows+=("$candidate") | ||
| } | ||
|
|
||
| if [ "$continuous_improvement" = true ]; then | ||
| for workflow in "${continuous_improvement_workflows[@]}"; do | ||
| append_workflow_if_missing "$workflow" | ||
| done | ||
| fi | ||
|
|
||
| if [ "${#workflows[@]}" -eq 0 ]; then | ||
| echo "Workflow list cannot be empty." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| workflow_dir=".github/workflows" | ||
| created_files=() | ||
|
|
||
| if [ "$dry_run" = true ]; then | ||
| echo "dry-run: mkdir -p $workflow_dir" | ||
| else | ||
| mkdir -p "$workflow_dir" | ||
| fi | ||
|
|
||
| for workflow in "${workflows[@]}"; do | ||
| [ -n "$workflow" ] || continue | ||
| src="$base_url/gh-agent-workflows/$workflow/example.yml" | ||
| dest="$workflow_dir/trigger-$workflow.yml" | ||
| if [ "$dry_run" = true ]; then | ||
| echo "dry-run: curl -fsSL $src -o $dest" | ||
| else | ||
| curl -fsSL "$src" -o "$dest" | ||
| created_files+=("$dest") | ||
| fi | ||
| done | ||
|
|
||
| maintenance_src="$base_url/.github/workflows/agentics-maintenance.yml" | ||
| maintenance_dest="$workflow_dir/agentics-maintenance.yml" | ||
| if [ "$dry_run" = true ]; then | ||
| echo "dry-run: curl -fsSL $maintenance_src -o $maintenance_dest" | ||
| else | ||
| curl -fsSL "$maintenance_src" -o "$maintenance_dest" | ||
| created_files+=("$maintenance_dest") | ||
| fi | ||
|
|
||
| if [ "$skip_secret" = false ]; then | ||
| token="${COPILOT_GITHUB_TOKEN:-}" | ||
| if [ -z "$token" ]; then | ||
| if [ "$dry_run" = true ]; then | ||
| echo "dry-run: gh auth refresh -h github.com -s copilot-requests" | ||
| echo "dry-run: gh auth token" | ||
| else | ||
| gh auth refresh -h github.com -s copilot-requests >/dev/null | ||
| token="$(gh auth token)" | ||
| fi | ||
| fi | ||
|
|
||
| if [ -z "$token" ] && [ "$dry_run" = false ]; then | ||
| echo "Unable to read token. Set COPILOT_GITHUB_TOKEN and rerun, or use --skip-secret." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$dry_run" = true ]; then | ||
| echo "dry-run: gh secret set COPILOT_GITHUB_TOKEN --repo $repo --body (token)" | ||
| else | ||
| gh secret set COPILOT_GITHUB_TOKEN --repo "$repo" --body "$token" | ||
|
github-actions[bot] marked this conversation as resolved.
Outdated
github-actions[bot] marked this conversation as resolved.
Outdated
|
||
| fi | ||
| unset token | ||
| fi | ||
|
|
||
| if [ "$dry_run" = true ]; then | ||
|
github-actions[bot] marked this conversation as resolved.
Outdated
|
||
| echo "dry-run: git checkout -b $branch" | ||
| else | ||
| if git show-ref --verify --quiet "refs/heads/$branch"; then | ||
| git checkout "$branch" | ||
| else | ||
| git checkout -b "$branch" | ||
| fi | ||
| fi | ||
|
|
||
| if [ "$dry_run" = true ]; then | ||
| echo "dry-run: git add .github/workflows/trigger-*.yml .github/workflows/agentics-maintenance.yml" | ||
| echo "dry-run: git commit -m \"Add gh-aw workflows via quick setup\"" | ||
| echo "dry-run: git push -u origin $branch" | ||
| echo "dry-run: gh pr create --repo $repo --fill" | ||
| exit 0 | ||
| fi | ||
|
|
||
| git add "${created_files[@]}" | ||
|
|
||
| if git diff --cached --quiet; then | ||
| echo "No changes to commit." | ||
| exit 0 | ||
| fi | ||
|
|
||
| git commit -m "Add gh-aw workflows via quick setup" | ||
| git push -u origin "$branch" | ||
| gh pr create --repo "$repo" --fill | ||
|
|
||
| echo "Installed workflows: ${workflows[*]}" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.