#!/bin/bash # Windmill Workflow Git Auto-Sync Script # このスクリプトは、Windmillワークフローを自動的にGitにコミットします set -e # 色付き出力 GREEN='\033[0;32m' YELLOW='\033[1;33m'#!/bin/bash # Windmill Workflow Git Auto-Sync Script for Gitea # このスクリプトは、Windmillワークフローを自動的にGiteaにコミット&プッシュします set -e # 色付き出力 GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' # No Color echo -e "${GREEN}=== Windmill Workflow Git Sync (Gitea) ===${NC}" # 作業ディレクトリに移動 cd /workspace # PATHを設定 export PATH=~/.npm-global/bin:$PATH # Git設定(safe.directoryエラー対策) git config --global --add safe.directory /workspace git config --global user.email "bot@example.com" git config --global user.name "Windmill Bot" # Windmillから最新を取得 echo -e "${YELLOW}Pulling from Windmill...${NC}" wmill sync pull --skip-variables --skip-secrets --skip-resources --yes # 変更があるか確認 if [[ -n $(git status --porcelain) ]]; then echo -e "${YELLOW}Changes detected, committing to Git...${NC}" # 変更をステージング git add -A # コミット TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S') git commit -m "Auto-sync: ${TIMESTAMP} Synced workflows from Windmill workspace" # Giteaにプッシュ echo -e "${YELLOW}Pushing to Gitea...${NC}" git push origin main || { echo -e "${RED}Failed to push to Gitea. Check credentials.${NC}" # トークンや認証情報が設定されていない場合のヒント echo -e "${YELLOW}Hint: Ensure you have set up git credentials or use a token in the remote URL.${NC}" exit 1 } echo -e "${GREEN}✓ Changes pushed to Gitea${NC}" else echo -e "${GREEN}✓ No changes detected${NC}" fi echo -e "${GREEN}=== Sync Complete ===${NC}"