windmill-sync-devstageprod-example

Example repo that demonstrate how to use a github repo as source of truth for part or all of your Windmill workspace.

This repo extends the windmill-sync-example with a dev/staging/prod setup based on having the sync done on different folders.

There are 3 folders:

  • dev
  • staging
  • prod

Each folder corresponds to a windmill workspace.

Locally, you will want to add those 3 workspaces:

wmill workspace add
  1. Pass the name you are gonna use for the workspace (dev/staging/prod) on your local machine to switch back and forth
  2. Pass name of the workspace-id on the remote (findable in the workspace list)
  3. Pass the url of the remote (https://app.windmill.dev/ for cloud hosted instances)
  4. Pass a token

Then locally, use:

wmill workspace switch <NAME>

to switch between workspaces.

The current workspace is stored globally and is not tied to the folder you are currently in.

Users of this repo can commit changes to the main branches and have it deployed on the windmill workspace corresponding to their dev/staging/prod folder/workspace thanks to a github action that will simply uses the windmill cli's wmill sync push under the hood.

This repo is used for syncing with the example folder on the demo workspace

Setup

Write access to the workspace is required. This is done using an access token. To generate a new token log into your windmill instance (https://app.windmill.dev/ for cloud hosted instances) and navigate to the account settings, which contains a "Tokens" section, use the relevant button there to generate a new token. Note that you will only be able to copy this token once!

Add an environment "windmill" to the repository via the settings. You may name this anything, but will need to adjust the workflow accordingly. Then add a secret "WMILL_TOKEN" to this environment.

Edit the workflows:

  • .github/workflows/push-on-merge.yaml to push on merge to main, usually you'll only need to fill out the env variables, then activate GitHub actions by navigating to the "Actions" tab in GitHub. You may want to run the action once manually to see that everything works.

  • .github/workflows/pull-workspace.yaml to sync back any changes made in Windmill UI to this repo under the form of either a Pull Request or a commit to main directly.

Security

We recommend creating and using a separate account in Windmill from which to use the token of. This will allow better tracking of the use of the token.

It may additionally be useful to restrict the GitHub environment. The GitHub help article goes into detail of all the options.

.wmillignore

Use the .wmillignore file to filter the contents to sync (like only the content of some folders), it supports the .gitignore syntax.

The .wmillignore is in each folder.