ワークフローの変更をgitに記録
This commit is contained in:
@@ -81,6 +81,8 @@ services:
|
|||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- worker_dependency_cache:/tmp/windmill/cache
|
- worker_dependency_cache:/tmp/windmill/cache
|
||||||
- worker_logs:/tmp/windmill/logs
|
- worker_logs:/tmp/windmill/logs
|
||||||
|
# mount the windmill workspace directory for git sync workflow
|
||||||
|
- /home/akira/develop/windmill:/workspace
|
||||||
|
|
||||||
logging: *default-logging
|
logging: *default-logging
|
||||||
|
|
||||||
|
|||||||
88
workflows/u/antigravity/git_sync__flow/a.sh
Normal file
88
workflows/u/antigravity/git_sync__flow/a.sh
Normal file
@@ -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 ==="
|
||||||
17
workflows/u/antigravity/git_sync__flow/flow.yaml
Normal file
17
workflows/u/antigravity/git_sync__flow/flow.yaml
Normal file
@@ -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: []
|
||||||
@@ -3,6 +3,7 @@ includes:
|
|||||||
- f/**
|
- f/**
|
||||||
- u/**
|
- u/**
|
||||||
- g/**
|
- g/**
|
||||||
|
- schedules/**
|
||||||
excludes: []
|
excludes: []
|
||||||
codebases: []
|
codebases: []
|
||||||
skipVariables: false
|
skipVariables: false
|
||||||
@@ -13,7 +14,7 @@ skipScripts: false
|
|||||||
skipFlows: false
|
skipFlows: false
|
||||||
skipApps: false
|
skipApps: false
|
||||||
skipFolders: false
|
skipFolders: false
|
||||||
includeSchedules: false
|
includeSchedules: true
|
||||||
includeTriggers: false
|
includeTriggers: false
|
||||||
includeUsers: false
|
includeUsers: false
|
||||||
includeGroups: false
|
includeGroups: false
|
||||||
|
|||||||
Reference in New Issue
Block a user