From 3afdbd1e2e92152f3edd53032f873f172bbe59c7 Mon Sep 17 00:00:00 2001 From: Akira Date: Fri, 13 Feb 2026 15:41:59 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AF=E3=83=BC=E3=82=AF=E3=83=95=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=81=AE=E5=A4=89=E6=9B=B4=E3=82=92git=E3=81=AB?= =?UTF-8?q?=E8=A8=98=E9=8C=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 2 + workflows/u/antigravity/git_sync__flow/a.sh | 88 +++++++++++++++++++ .../u/antigravity/git_sync__flow/flow.yaml | 17 ++++ workflows/wmill.yaml | 3 +- 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 workflows/u/antigravity/git_sync__flow/a.sh create mode 100644 workflows/u/antigravity/git_sync__flow/flow.yaml diff --git a/docker-compose.yml b/docker-compose.yml index 52f6e26..1a0787b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -81,6 +81,8 @@ services: - /var/run/docker.sock:/var/run/docker.sock - worker_dependency_cache:/tmp/windmill/cache - worker_logs:/tmp/windmill/logs + # mount the windmill workspace directory for git sync workflow + - /home/akira/develop/windmill:/workspace logging: *default-logging diff --git a/workflows/u/antigravity/git_sync__flow/a.sh b/workflows/u/antigravity/git_sync__flow/a.sh new file mode 100644 index 0000000..4f29298 --- /dev/null +++ b/workflows/u/antigravity/git_sync__flow/a.sh @@ -0,0 +1,88 @@ +#!/bin/bash +set -e + +echo "=== Windmill Workflow Git Sync ===" + +# ----------------------------------------------------------------------------- +# Configuration & Checks +# ----------------------------------------------------------------------------- + +# Ensure Windmill CLI variables are set +if [[ -z "${WM_TOKEN}" ]]; then + echo "Warning: WM_TOKEN is not set. attempting to continue assuming ~/.config/windmill/config.toml exists." + echo "If this fails, please set WM_TOKEN and WM_BASE_URL variables in the Windmill workspace settings or workflow input." +fi + +# Configure Git for the container +# This is necessary because the script runs inside a Docker container +# where the global git config might not be set. +echo "Configuring Git..." +git config --global --add safe.directory /workspace +if [ -z "$(git config --global user.email)" ]; then + git config --global user.email "windmill-bot@example.com" + git config --global user.name "Windmill Bot" +fi + +# ----------------------------------------------------------------------------- +# Execution +# ----------------------------------------------------------------------------- + +# Move to workspace directory (mapped to /home/akira/develop/windmill) +# We need to be in the workflows directory where wmill.yaml is likely located +# to ensure configuration (like includeSchedules) is respected. +if [ -d "/workspace/workflows" ]; then + cd /workspace/workflows +elif [ -d "/workspace" ]; then + cd /workspace +else + echo "Error: /workspace directory not found. Is the volume mounted correctly?" + exit 1 +fi + +# Set PATH to ensure wmill is available +export PATH=~/.npm-global/bin:$PATH + +# Check if wmill is available +if ! command -v wmill &> /dev/null; then + echo "wmill command not found. Attempting to install windmill-client..." + # Try installing using pip if npm is not available, or npm + if command -v npm &> /dev/null; then + npm install -g windmill-cli + else + echo "Error: npm not found. Cannot install wmill client." + exit 1 + fi +fi + +# Pull latest from Windmill +echo "Pulling from Windmill..." +# wmill sync pull will use the workspace defined in wmill.yaml or env vars. +# We add --yes to avoid prompts. +if wmill sync pull --skip-variables --skip-secrets --skip-resources --yes; then + echo "Successfully pulled from Windmill." +else + echo "Error: wmill sync pull failed. Check your WM_TOKEN and connection." + exit 1 +fi + +# Check for changes +if [[ -n $(git status --porcelain) ]]; then + echo "Changes detected, committing to Git..." + + # Stage changes + git add -A + + # Commit + TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S') + git commit -m "Auto-sync: ${TIMESTAMP} + +Synced workflows from Windmill workspace" + + echo "✓ Changes committed to Git" + echo "Successfully synced and committed changes at ${TIMESTAMP}" +else + echo "✓ No changes detected" + echo "No changes to commit" +fi + +echo "=== Sync Complete ===" diff --git a/workflows/u/antigravity/git_sync__flow/flow.yaml b/workflows/u/antigravity/git_sync__flow/flow.yaml new file mode 100644 index 0000000..cf6f6bd --- /dev/null +++ b/workflows/u/antigravity/git_sync__flow/flow.yaml @@ -0,0 +1,17 @@ +summary: Git Sync Workflow +description: Automatically sync Windmill workflows to Git repository +value: + modules: + - id: a + value: + type: rawscript + content: '!inline a.sh' + input_transforms: {} + lock: '' + language: bash +schema: + $schema: 'https://json-schema.org/draft/2020-12/schema' + type: object + order: [] + properties: {} + required: [] diff --git a/workflows/wmill.yaml b/workflows/wmill.yaml index 2100239..08f4c9e 100644 --- a/workflows/wmill.yaml +++ b/workflows/wmill.yaml @@ -3,6 +3,7 @@ includes: - f/** - u/** - g/** + - schedules/** excludes: [] codebases: [] skipVariables: false @@ -13,7 +14,7 @@ skipScripts: false skipFlows: false skipApps: false skipFolders: false -includeSchedules: false +includeSchedules: true includeTriggers: false includeUsers: false includeGroups: false