mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-20 18:35:14 +00:00
feat: add hooks functionality with automated workflows
- Introduced hooks to enable automated workflows triggered by specific events during GitHub Copilot sessions. - Added documentation for hooks in AGENTS.md and README.md. - Created a new directory structure for hooks, including README.md and hooks.json files. - Implemented two example hooks: Session Auto-Commit and Session Logger. - Developed scripts for logging session events and auto-committing changes. - Enhanced validation and parsing for hook metadata. - Updated build and validation scripts to accommodate new hooks functionality.
This commit is contained in:
45
hooks/session-auto-commit/auto-commit.sh
Executable file
45
hooks/session-auto-commit/auto-commit.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Session Auto-Commit Hook
|
||||
# Automatically commits and pushes changes when a Copilot session ends
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Check if SKIP_AUTO_COMMIT is set
|
||||
if [[ "${SKIP_AUTO_COMMIT:-}" == "true" ]]; then
|
||||
echo "⏭️ Auto-commit skipped (SKIP_AUTO_COMMIT=true)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if we're in a git repository
|
||||
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
|
||||
echo "⚠️ Not in a git repository"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check for uncommitted changes
|
||||
if [[ -z "$(git status --porcelain)" ]]; then
|
||||
echo "✨ No changes to commit"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "📦 Auto-committing changes from Copilot session..."
|
||||
|
||||
# Stage all changes
|
||||
git add -A
|
||||
|
||||
# Create timestamped commit
|
||||
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
git commit -m "auto-commit: $TIMESTAMP" --no-verify 2>/dev/null || {
|
||||
echo "⚠️ Commit failed"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Attempt to push
|
||||
if git push 2>/dev/null; then
|
||||
echo "✅ Changes committed and pushed successfully"
|
||||
else
|
||||
echo "⚠️ Push failed - changes committed locally"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user