Skip to content

Commit 90d3cb7

Browse files
authored
git sync v2 (#1063)
1 parent 3faf029 commit 90d3cb7

File tree

7 files changed

+384
-63
lines changed

7 files changed

+384
-63
lines changed
-109 KB
Loading

docs/advanced/11_git_sync/index.mdx

Lines changed: 90 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This video shows how to set up a Git repository for a workspace (Git sync - work
2424

2525
<iframe
2626
style={{ aspectRatio: '16/9' }}
27-
src="https://www.youtube.com/embed/tmYcrfc_mAc"
27+
src="https://www.youtube.com/embed/cHrREDmrnUM?vq=hd1080&hd=1&quality=highres"
2828
title="Git sync"
2929
frameBorder="0"
3030
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
@@ -46,23 +46,29 @@ Note that you can explicitly exclude (or include) specific files or folders to b
4646

4747
### Setup
4848

49-
#### Pull workspace locally
49+
#### 1. Initialize Git repository
5050

51-
For the Git repo to be representative of the entire workspace, it is recommended to set it up using the [Windmill CLI](../3_cli/index.mdx) before turning this option on.
51+
First, create a Git repository to store your Windmill workspace:
5252

53-
Use [Windmill CLI](../3_cli/index.mdx) to pull the workspace locally:
53+
**Option A: Create empty repository (Recommended)**
54+
55+
Create an empty Git repository on your Git provider (GitHub, GitLab, etc.) without any initial files. Windmill will populate it automatically in the next step.
56+
57+
**Option B: Manual CLI setup**
58+
59+
For more control, you can set up the repository manually using the [Windmill CLI](../3_cli/index.mdx):
60+
61+
1. Use [Windmill CLI](../3_cli/index.mdx) to pull the workspace locally:
5462

5563
```bash
5664
wmill sync pull
5765
```
5866

59-
![Pull workpsace](./pull_workspace.png 'Pull workspace')
60-
61-
#### Push workspace to GitHub
67+
Configure your [`wmill.yaml`](../3_cli/sync.mdx#wmillyaml) file with the desired filter settings before pushing to Git.
6268

63-
Create a Git repository (in the example, on GitHub).
69+
![Pull workpsace](./pull_workspace.png 'Pull workspace')
6470

65-
Run the following commands from the git repo folder to push the initial workspace content to the remote:
71+
2. Create a Git repository (in the example, on GitHub) and push the initial workspace content:
6672

6773
```bash
6874
git init
@@ -72,23 +78,32 @@ git commit -m 'Initial commit'
7278
git push -u origin main
7379
```
7480

75-
You now have your Windmill workspace on a GitHub repository. See the following section for an automated sync.
76-
77-
#### Setup in Windmill & GitHub token
81+
You now have your Windmill workspace on a GitHub repository.
7882

79-
In Windmill, create a [git_repository](https://hub.windmill.dev/resource_types/135/git_repository) resource pointing to the GitHub repository and containing a [token](https://github.com/settings/tokens) (with Read-and-write on "Contents"). You URL should be `https://[USERNAME]:[TOKEN]@github.com/[ORG|USER]/[REPO_NAME].git`.
83+
#### 2. Setup in Windmill
8084

81-
Add this resource to the workspace settings, in "Git sync" tab and `Save Git sync settings`.
85+
1. Go to workspace settings → Git Sync tab
86+
2. Click **+ Add connection**
87+
3. Create or select a [git_repository](../../integrations/git_repository.mdx) resource pointing to your Git repository. You have two authentication options:
88+
- **GitHub App**: Use the [GitHub App](../../integrations/git_repository.mdx#github-app) for simplified authentication and enhanced security
89+
- **Personal Access Token**: Use a [token](https://github.com/settings/tokens) with Read-and-write on "Contents". Your URL should be `https://[USERNAME]:[TOKEN]@github.com/[ORG|USER]/[REPO_NAME].git`
90+
4. Select sync mode ([sync mode or promotion mode](#sync-modes))
91+
5. Complete the configuration of the connection and save
8292

8393
![Git sync Setup](./git_sync_setup.png 'Git sync Setup')
8494

85-
And that's it! Now, all scripts, flows apps, resources, variables, schedules, resource types and triggers located in the workspace and `f/` [folders](../../core_concepts/8_groups_and_folders/index.mdx) will be pushed to the Git repository.
95+
If you chose Option A (empty repository), use the "Initialize Git repository" operation to automatically:
96+
- Create the `wmill.yaml` configuration file with your filter settings
97+
- Push the entire workspace content to the Git repository
98+
99+
If the repository already contains a `wmill.yaml` file, the settings will be automatically imported and applied to your workspace configuration.
86100

87-
You can filter on type if you don't want some items (e.g. variables) to be pushed to the Git repository.
101+
**Configuration settings**: Git sync filter settings are pulled from the [`wmill.yaml`](../3_cli/sync.mdx#wmillyaml) file in your repository. Once the connection is saved, you can update settings by changing `wmill.yaml` and pulling the settings via the corresponding button.
88102

89-
Additionally, you can filter on [path](../../core_concepts/16_roles_and_permissions/index.mdx#path), meaning only scripts, flows and apps with their path matching one of those filters will be synced to the Git repositories below. The filters allow '*'' and '**' characters, with '*'' matching any character allowed in paths until the next slash (/) and '**' matching anything including slashes. By default everything in [folders](../../core_concepts/8_groups_and_folders/index.mdx) will be synced.
90103

91-
##### Signing commits with GPG
104+
![Git sync Settings](./settings_pull.png 'Git sync Settings Pull')
105+
106+
#### Signing commits with GPG
92107

93108
If your repo requires signed commits, you can set up GPG on your Windmill instance.
94109

@@ -120,7 +135,7 @@ All commits will now be signed and commited as the user matching the email addre
120135
:::
121136

122137
#### Azure DevOps with Service Principal setup
123-
In Microsoft Entra ID, create an application and a secret (also known as Service Principal - an identity used by applications to access Azure resources).
138+
In Microsoft Entra ID, create an application and a secret (also known as Service Principal - an identity used by applications to access Azure resources).
124139
Create an `azure` resource on your Windmill instance with the application's `client_id`, `client_secret` and `tenant_id`.
125140
On Azure DevOps, add the application to the DevOps organization with the appropriate permissions.
126141
In Git sync settings of your Windmill instance, define a new repository with URL:
@@ -136,42 +151,79 @@ https://AZURE_DEVOPS_TOKEN(<path_to_the_azure_resource>)@dev.azure.com/<organiza
136151
Only scripts, flows and apps with their path matching one of the set filters will be synced to the Git repositories below. The filters allow `*'` and `**'` characters, with `*'` matching any character allowed in paths until the next slash (`/`) and `**'` matching anything including slashes.
137152
By default everything in folders (with rule `f/**`) will be synced.
138153

154+
You can configure:
155+
156+
- **Include paths**: Primary patterns for what to sync (e.g., `f/**`)
157+
- **Exclude paths**: Patterns to exclude after include checks
158+
139159
### Type filters
140160

141161
On top of the filter path [above](#path-filters), you can include only certain type of object to be synced with the Git repository.
142162
By default everything is synced.
143163

144164
You can filter on:
145-
- Scripts
146-
- Flows
147-
- Apps
148-
- Folders
149-
- Resource
150-
- Variables
151-
- Include secrets
152-
- Schedules
153-
- Resource types
154-
- Users
155-
- Groups
156-
- Triggers (HTTP routes, WebSocket, Postgres, Kafka, NATS, SQS, GCP Pub/Sub, MQTT)
165+
- **Scripts** - Individual scripts
166+
- **Flows** - Workflow definitions
167+
- **Apps** - Application definitions
168+
- **Folders** - Folder structure
169+
- **Resources** - Resource instances
170+
- **Variables** - Workspace variables
171+
- **Include secrets** - Option to include secret variables
172+
- **Schedules** - Scheduled job definitions
173+
- **Resource types**
174+
- **Users** - User definitions
175+
- **Groups** - Group definitions
176+
- **Triggers** - Event triggers (HTTP routes, WebSocket, Postgres, Kafka, NATS, SQS, GCP Pub/Sub, MQTT)
177+
- **Workspace settings** - Global workspace configuration
178+
- **Encryption key** - Workspace encryption key
157179

158180
## Repositories to sync
159181

160182
The changes will be deployed to all the repositories set in the Git sync settings.
161183

162-
### Create one branch per deployed object
184+
### Sync modes
185+
186+
You can choose between two sync modes for each repository:
187+
188+
#### Sync mode (default)
189+
Changes are committed directly to the branch specified in the [git_repository](../../integrations/git_repository.mdx) resource. This is the standard mode for simple workspace synchronization.
190+
191+
#### Promotion mode
192+
Windmill will create branches per deployed object based on its path, prefixed with 'wm_deploy/'. This enables advanced deployment workflows with pull requests and code review processes.
193+
194+
When promotion mode is enabled, you can choose to:
195+
- **Create one branch per deployed object** (default)
196+
- **Group deployed objects by folder**: Create a branch per folder containing objects being deployed instead
197+
198+
You can configure promotion-specific sync behavior using `promotionOverrides` in your [`wmill.yaml`](../3_cli/sync.mdx#wmillyaml) file. This allows different filter settings when promoting changes to specific branches.
163199

164-
If set, Windmill will create a unique branch per object being pushed based on its path, prefixed with 'wm_deploy/'.
200+
This promotion mode is used to [deploy to a prod workspace using a git workflow](#git-sync---item-mode-deploy-to-prod-using-a-git-workflow).
165201

166-
It is used to [deploy to a prod workspace using a git workflow](#git-sync---item-mode-deploy-to-prod-using-a-git-workflow).
202+
## Repository operations
167203

168-
### Group deployed objects by folder
204+
Each configured repository supports several operations:
169205

170-
Instead of creating a branch per object, Windmill will create a branch per folder containing objects being deployed.
206+
- **Test connection**: Verify repository access and credentials
207+
- **Preview changes**: Perform a dry-run to see what would be synced
208+
- **Push to repository**: Send workspace content to git repository
209+
- **Pull from repository**: Get changes from git repository to workspace
210+
- **Pull settings**: Get only wmill.yaml configuration changes
211+
- **Initialize repository**: Set up new git repository with Windmill structure
212+
213+
## wmill.yaml integration
214+
215+
Git sync settings can be controlled via the [`wmill.yaml`](../3_cli/sync.mdx#wmillyaml) file in your repository root. This enables:
216+
217+
- **CLI compatibility**: Settings configured in the UI are compatible with [Windmill CLI](../3_cli/index.mdx)
218+
- **Version-controlled configuration**: Your sync settings are stored in git alongside your code
219+
- **Branch-specific overrides**: Different sync behavior per git branch
220+
- **Promotion-specific settings**: Special configuration for deployment workflows
221+
222+
The frontend will detect existing `wmill.yaml` files and merge settings appropriately.
171223

172224
## Exclude specific types for this repository only
173225

174-
You can exclude specific types (scripts, flows, apps, folders) per repository.
226+
You can exclude specific types per repository, overriding the global workspace filters.
175227

176228
## Git sync - Item mode: Deploy to prod using a git workflow
177229

@@ -210,4 +262,4 @@ More details at:
210262
description="Install the Windmill GitHub app to simplify setting up Git sync"
211263
href="/docs/integrations/git_repository#github-app"
212264
/>
213-
</div>
265+
</div>
178 KB
Loading

docs/advanced/13_version_control/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This video shows how to set up a Git repository for a workspace (Git sync - work
1212

1313
<iframe
1414
style={{ aspectRatio: '16/9' }}
15-
src="https://www.youtube.com/embed/tmYcrfc_mAc"
15+
src="https://www.youtube.com/embed/cHrREDmrnUM?vq=hd1080&hd=1&quality=highres"
1616
title="Git sync"
1717
frameBorder="0"
1818
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
@@ -60,4 +60,4 @@ More details at:
6060
description="Scripts, when deployed, can have a parent script identified by its hash."
6161
href="/docs/core_concepts/versioning"
6262
/>
63-
</div>
63+
</div>

0 commit comments

Comments
 (0)