Skip to content

Commit

Permalink
feat(ci): add GitHub Action support
Browse files Browse the repository at this point in the history
  • Loading branch information
pandatix committed Apr 26, 2024
1 parent a81759d commit 743a2a8
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 12 deletions.
44 changes: 41 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -52,11 +90,11 @@ steps:
The following resumes what Victor does for you.

<div align="center">
<img src="res/how-it-works.png" alt="How it works in a Drone pipeline">
<img src="res/how-it-works.excalidraw.png" alt="How it works in a Drone pipeline">
</div>

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.

Expand Down
41 changes: 41 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -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 (<name> <version>) to install before performing the update.'
configuration:
description: 'List of configurations tuples (<key> <value>) 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 }}
18 changes: 9 additions & 9 deletions cmd/victor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@ 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{
Name: "statefile",
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{
Expand All @@ -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 (<name> <version>) 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 (<key> <value>) 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,
Expand Down
Binary file added res/how-it-works.excalidraw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed res/how-it-works.png
Binary file not shown.

0 comments on commit 743a2a8

Please sign in to comment.