diff --git a/README.md b/README.md index 0af6afb..5d7b007 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,45 @@ ## How to use -You can drop the following into your Drone pipeline (`type: docker`). +You can drop the following into your GitHub Action workflow. + +```yaml +name: 'My workflow' + +on: + push: + branches: + - 'main' + +jobs: + my-job: + runs-on: 'ubuntu-latest' + steps: + - name: 'Victor CD' + uses: 'ctfer-io/victor@v0' + with: + # Webserver related options + statefile: 'https://my-webserver.dev/project.stack.state' + username: ${{ secrets.WEBDAV_USERNAME }} + password: ${{ secrets.WEBDAV_PASSWORD }} + # Pulumi related options + passphrase: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} + context: './deploy' + resources: + - "kubernetes 3.29.1" + - "random 4.13.2" + configuration: + - "namespace prod" + - "version v1.5.2" + server: 'https://my-webserver.dev/pulumi' + outputs: 'outputs.json' + # Specific environment variables that fit your context (e.g. offline) + env: + MY_VAR1: 'my_value' + MY_VAR2: ${{ secrets.MY_VAR2 }} +``` + +Alternatively, you can use it in a Drone pipeline (`type: docker`). ```yaml steps: @@ -52,11 +90,11 @@ steps: The following resumes what Victor does for you.
- How it works in a Drone pipeline + How it works in a Drone pipeline
Here are more explanation: - 1. **Get stack if exist**: Victor create a new Pulumi workspace in your Drone pipeline, then create a stack, and if the webserver contains a state file, loads it. This enable the following to work properly. + 1. **Get stack if exist**: Victor create a new Pulumi workspace in your GitHub Action workflow or Drone pipeline, then create a stack, and if the webserver contains a state file, loads it. This enable the following to work properly. 2. **Update**: by comparing the existing and actualised resources (does a refresh first) to the target, Victor enable fine-grained continuous deployment of your resources. 3. **Push updated stack**: finally, Victor exports the stack state file and uploads it in the webserver such that future iterations will be able to load it, to really do **continuous** deployment. diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..d577f3c --- /dev/null +++ b/action.yaml @@ -0,0 +1,41 @@ +name: 'Victor' +author: 'ctfer-io' +description: 'Continuous Deployment of a Pulumi stack, with file storing in a web server.' + +inputs: + verbose: + description: 'Turn on the verbose mode i.e. writes the Pulumi state outputs to stdout.' + statefile: + description: 'Where the Pulumi stack state file is supposed to be saved. If it does not currently exist, Victor will create a brand new one.' + required: true + username: + description: 'What username to use when getting/pushing the Pulumi stack state file. Don''t set for unauthenticated.' + password: + description: 'What password to use when getting/pushing the Pulumi stack state file. Don''t set for unauthenticated.' + passphrase: + description: 'Pulumi stack password, used to decipher and recipher the state.' + context: + description: 'Where to deploy i.e. the Pulumi entrypoint (the directory pointing to a `main.go` file containing the `pulumi.Run` call).' + server: + description: 'Where to download the Pulumi plugin resources. If set, overrides the online default mode of Pulumi.' + resources: + description: 'List of Pulumi plugin resources ( ) to install before performing the update.' + configuration: + description: 'List of configurations tuples ( ) to pass to the Pulumi entrypoint. Does not support secrets yet.' + outputs: + description: 'Where to write the Pulumi stack outputs. If set to "-" will write to stdout, else to the given filename.' + +runs: + using: docker + image: 'Dockerfile' + env: + VERBOSE: ${{ inputs.verbose }} + STATEFILE: ${{ inputs.statefile }} + USERNAME: ${{ inputs.username }} + PASSWORD: ${{ inputs.password }} + PULUMI_CONFIG_PASSPHRASE: ${{ inputs.passphrase }} + CONTEXT: ${{ inputs.context }} + SERVER: ${{ inputs.server }} + RESOURCES: ${{ inputs.resources }} + CONFIGURATION: ${{ inputs.configuration }} + OUTPUTS: ${{ inputs.outputs }} diff --git a/cmd/victor/main.go b/cmd/victor/main.go index 65ef60f..aba2add 100644 --- a/cmd/victor/main.go +++ b/cmd/victor/main.go @@ -39,7 +39,7 @@ func main() { Name: "verbose", Usage: "Turn on the verbose mode i.e. writes the Pulumi state outputs to stdout.", Required: false, - EnvVars: []string{"PLUGIN_VERBOSE"}, + EnvVars: []string{"VERBOSE", "PLUGIN_VERBOSE"}, }, // Webserver related &cli.StringFlag{ @@ -47,21 +47,21 @@ func main() { Category: catWebserver, Usage: "Where the Pulumi stack state file is supposed to be saved. If it does not currently exist, Victor will create a brand new one.", Required: true, - EnvVars: []string{"PLUGIN_STATEFILE"}, + EnvVars: []string{"STATEFILE", "PLUGIN_STATEFILE"}, }, &cli.StringFlag{ Name: "username", Category: catWebserver, Usage: "What username to use when getting/pushing the Pulumi stack state file. Don't set for unauthenticated.", Required: false, - EnvVars: []string{"PLUGIN_USERNAME"}, + EnvVars: []string{"USERNAME", "PLUGIN_USERNAME"}, }, &cli.StringFlag{ Name: "password", Category: catWebserver, Usage: "What password to use when getting/pushing the Pulumi stack state file. Don't set for unauthenticated.", Required: false, - EnvVars: []string{"PLUGIN_PASSWORD"}, + EnvVars: []string{"PASSWORD", "PLUGIN_PASSWORD"}, }, // Pulumi related &cli.StringFlag{ @@ -77,35 +77,35 @@ func main() { Usage: "Where to deploy i.e. the Pulumi entrypoint (the directory pointing to a `main.go` file containing the `pulumi.Run` call).", Required: false, Value: ".", - EnvVars: []string{"PLUGIN_CONTEXT"}, + EnvVars: []string{"CONTEXT", "PLUGIN_CONTEXT"}, }, &cli.StringFlag{ Name: "server", Category: catPulumi, Usage: "Where to download the Pulumi plugin resources. If set, overrides the online default mode of Pulumi.", Required: false, - EnvVars: []string{"PLUGIN_SERVER"}, + EnvVars: []string{"SERVER", "PLUGIN_SERVER"}, }, &cli.StringSliceFlag{ Name: "resources", Category: catPulumi, Usage: "List of Pulumi plugin resources ( ) to install before performing the update.", Required: false, - EnvVars: []string{"PLUGIN_RESOURCES"}, + EnvVars: []string{"RESOURCES", "PLUGIN_RESOURCES"}, }, &cli.StringSliceFlag{ Name: "configuration", Category: catPulumi, Usage: "List of configurations tuples ( ) to pass to the Pulumi entrypoint. Does not support secrets yet.", Required: false, - EnvVars: []string{"PLUGIN_CONFIGURATION"}, + EnvVars: []string{"CONFIGURATION", "PLUGIN_CONFIGURATION"}, }, &cli.StringFlag{ Name: "outputs", Category: catPulumi, Usage: "Where to write the Pulumi stack outputs. If set to \"-\" will write to stdout, else to the given filename.", Required: false, - EnvVars: []string{"PLUGIN_OUTPUTS"}, + EnvVars: []string{"OUTPUTS", "PLUGIN_OUTPUTS"}, }, }, Action: run, diff --git a/res/how-it-works.excalidraw.png b/res/how-it-works.excalidraw.png new file mode 100644 index 0000000..e0b3df6 Binary files /dev/null and b/res/how-it-works.excalidraw.png differ diff --git a/res/how-it-works.png b/res/how-it-works.png deleted file mode 100644 index d1494a6..0000000 Binary files a/res/how-it-works.png and /dev/null differ