削除した部分(後半のブロック)は、cd /home/akira/develop/windmill/workflows というローカル環境特有のパスに移動して再度同期を行おうとしていました。 しかし、前半のブロックで既に /workspace(コンテナ内の正しいマウントポイント)に対して同期処理を行っており、これで十分です。 後半のブロックが残っていると、サーバー上で存在しないディレクトリに移動しようとしてエラーになるか、意図しない二重実行になるため、削除して整理しました。 これでスクリプトはシンプルになり、サーバー環境に適したものになりました。 変更をGiteaにプッシュしましたので、SERVER_SETUP.md の手順に従ってサーバー上で設定を進めてください。
69 lines
1.9 KiB
Bash
Executable File
69 lines
1.9 KiB
Bash
Executable File
#!/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}"
|