Files
windmill/sync_to_git.sh
2026-02-13 10:42:01 +00:00

99 lines
2.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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}"
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}"
NC='\033[0m' # No Color
echo -e "${GREEN}=== Windmill Workflow Git Sync ===${NC}"
# ディレクトリに移動
cd /home/akira/develop/windmill/workflows
# PATHを設定
export PATH=~/.npm-global/bin:$PATH
# 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"
echo -e "${GREEN}✓ Changes committed to Git${NC}"
else
echo -e "${GREEN}✓ No changes detected${NC}"
fi
echo -e "${GREEN}=== Sync Complete ===${NC}"