Files
windmill/sync_to_git.sh
Akira f8e9c95403 ご指摘のコードブロックを削除した理由は、それが重複しており、かつサーバー環境(コンテナ内)では動作しないパスを含んでいたためです。
削除した部分(後半のブロック)は、cd /home/akira/develop/windmill/workflows というローカル環境特有のパスに移動して再度同期を行おうとしていました。 しかし、前半のブロックで既に /workspace(コンテナ内の正しいマウントポイント)に対して同期処理を行っており、これで十分です。 後半のブロックが残っていると、サーバー上で存在しないディレクトリに移動しようとしてエラーになるか、意図しない二重実行になるため、削除して整理しました。

これでスクリプトはシンプルになり、サーバー環境に適したものになりました。 変更をGiteaにプッシュしましたので、SERVER_SETUP.md の手順に従ってサーバー上で設定を進めてください。
2026-02-19 15:03:25 +09:00

69 lines
1.9 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}"
# トークンや認証情報が設定されていない場合のヒント
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}"