Skip to content

Commit 743a2a8

Browse files
committed
feat(ci): add GitHub Action support
1 parent a81759d commit 743a2a8

File tree

5 files changed

+91
-12
lines changed

5 files changed

+91
-12
lines changed

README.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,45 @@
1515

1616
## How to use
1717

18-
You can drop the following into your Drone pipeline (`type: docker`).
18+
You can drop the following into your GitHub Action workflow.
19+
20+
```yaml
21+
name: 'My workflow'
22+
23+
on:
24+
push:
25+
branches:
26+
- 'main'
27+
28+
jobs:
29+
my-job:
30+
runs-on: 'ubuntu-latest'
31+
steps:
32+
- name: 'Victor CD'
33+
uses: 'ctfer-io/victor@v0'
34+
with:
35+
# Webserver related options
36+
statefile: 'https://my-webserver.dev/project.stack.state'
37+
username: ${{ secrets.WEBDAV_USERNAME }}
38+
password: ${{ secrets.WEBDAV_PASSWORD }}
39+
# Pulumi related options
40+
passphrase: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
41+
context: './deploy'
42+
resources:
43+
- "kubernetes 3.29.1"
44+
- "random 4.13.2"
45+
configuration:
46+
- "namespace prod"
47+
- "version v1.5.2"
48+
server: 'https://my-webserver.dev/pulumi'
49+
outputs: 'outputs.json'
50+
# Specific environment variables that fit your context (e.g. offline)
51+
env:
52+
MY_VAR1: 'my_value'
53+
MY_VAR2: ${{ secrets.MY_VAR2 }}
54+
```
55+
56+
Alternatively, you can use it in a Drone pipeline (`type: docker`).
1957

2058
```yaml
2159
steps:
@@ -52,11 +90,11 @@ steps:
5290
The following resumes what Victor does for you.
5391

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

5896
Here are more explanation:
59-
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.
97+
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.
6098
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.
6199
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.
62100

action.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: 'Victor'
2+
author: 'ctfer-io'
3+
description: 'Continuous Deployment of a Pulumi stack, with file storing in a web server.'
4+
5+
inputs:
6+
verbose:
7+
description: 'Turn on the verbose mode i.e. writes the Pulumi state outputs to stdout.'
8+
statefile:
9+
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.'
10+
required: true
11+
username:
12+
description: 'What username to use when getting/pushing the Pulumi stack state file. Don''t set for unauthenticated.'
13+
password:
14+
description: 'What password to use when getting/pushing the Pulumi stack state file. Don''t set for unauthenticated.'
15+
passphrase:
16+
description: 'Pulumi stack password, used to decipher and recipher the state.'
17+
context:
18+
description: 'Where to deploy i.e. the Pulumi entrypoint (the directory pointing to a `main.go` file containing the `pulumi.Run` call).'
19+
server:
20+
description: 'Where to download the Pulumi plugin resources. If set, overrides the online default mode of Pulumi.'
21+
resources:
22+
description: 'List of Pulumi plugin resources (<name> <version>) to install before performing the update.'
23+
configuration:
24+
description: 'List of configurations tuples (<key> <value>) to pass to the Pulumi entrypoint. Does not support secrets yet.'
25+
outputs:
26+
description: 'Where to write the Pulumi stack outputs. If set to "-" will write to stdout, else to the given filename.'
27+
28+
runs:
29+
using: docker
30+
image: 'Dockerfile'
31+
env:
32+
VERBOSE: ${{ inputs.verbose }}
33+
STATEFILE: ${{ inputs.statefile }}
34+
USERNAME: ${{ inputs.username }}
35+
PASSWORD: ${{ inputs.password }}
36+
PULUMI_CONFIG_PASSPHRASE: ${{ inputs.passphrase }}
37+
CONTEXT: ${{ inputs.context }}
38+
SERVER: ${{ inputs.server }}
39+
RESOURCES: ${{ inputs.resources }}
40+
CONFIGURATION: ${{ inputs.configuration }}
41+
OUTPUTS: ${{ inputs.outputs }}

cmd/victor/main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,29 @@ func main() {
3939
Name: "verbose",
4040
Usage: "Turn on the verbose mode i.e. writes the Pulumi state outputs to stdout.",
4141
Required: false,
42-
EnvVars: []string{"PLUGIN_VERBOSE"},
42+
EnvVars: []string{"VERBOSE", "PLUGIN_VERBOSE"},
4343
},
4444
// Webserver related
4545
&cli.StringFlag{
4646
Name: "statefile",
4747
Category: catWebserver,
4848
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.",
4949
Required: true,
50-
EnvVars: []string{"PLUGIN_STATEFILE"},
50+
EnvVars: []string{"STATEFILE", "PLUGIN_STATEFILE"},
5151
},
5252
&cli.StringFlag{
5353
Name: "username",
5454
Category: catWebserver,
5555
Usage: "What username to use when getting/pushing the Pulumi stack state file. Don't set for unauthenticated.",
5656
Required: false,
57-
EnvVars: []string{"PLUGIN_USERNAME"},
57+
EnvVars: []string{"USERNAME", "PLUGIN_USERNAME"},
5858
},
5959
&cli.StringFlag{
6060
Name: "password",
6161
Category: catWebserver,
6262
Usage: "What password to use when getting/pushing the Pulumi stack state file. Don't set for unauthenticated.",
6363
Required: false,
64-
EnvVars: []string{"PLUGIN_PASSWORD"},
64+
EnvVars: []string{"PASSWORD", "PLUGIN_PASSWORD"},
6565
},
6666
// Pulumi related
6767
&cli.StringFlag{
@@ -77,35 +77,35 @@ func main() {
7777
Usage: "Where to deploy i.e. the Pulumi entrypoint (the directory pointing to a `main.go` file containing the `pulumi.Run` call).",
7878
Required: false,
7979
Value: ".",
80-
EnvVars: []string{"PLUGIN_CONTEXT"},
80+
EnvVars: []string{"CONTEXT", "PLUGIN_CONTEXT"},
8181
},
8282
&cli.StringFlag{
8383
Name: "server",
8484
Category: catPulumi,
8585
Usage: "Where to download the Pulumi plugin resources. If set, overrides the online default mode of Pulumi.",
8686
Required: false,
87-
EnvVars: []string{"PLUGIN_SERVER"},
87+
EnvVars: []string{"SERVER", "PLUGIN_SERVER"},
8888
},
8989
&cli.StringSliceFlag{
9090
Name: "resources",
9191
Category: catPulumi,
9292
Usage: "List of Pulumi plugin resources (<name> <version>) to install before performing the update.",
9393
Required: false,
94-
EnvVars: []string{"PLUGIN_RESOURCES"},
94+
EnvVars: []string{"RESOURCES", "PLUGIN_RESOURCES"},
9595
},
9696
&cli.StringSliceFlag{
9797
Name: "configuration",
9898
Category: catPulumi,
9999
Usage: "List of configurations tuples (<key> <value>) to pass to the Pulumi entrypoint. Does not support secrets yet.",
100100
Required: false,
101-
EnvVars: []string{"PLUGIN_CONFIGURATION"},
101+
EnvVars: []string{"CONFIGURATION", "PLUGIN_CONFIGURATION"},
102102
},
103103
&cli.StringFlag{
104104
Name: "outputs",
105105
Category: catPulumi,
106106
Usage: "Where to write the Pulumi stack outputs. If set to \"-\" will write to stdout, else to the given filename.",
107107
Required: false,
108-
EnvVars: []string{"PLUGIN_OUTPUTS"},
108+
EnvVars: []string{"OUTPUTS", "PLUGIN_OUTPUTS"},
109109
},
110110
},
111111
Action: run,

res/how-it-works.excalidraw.png

152 KB
Loading

res/how-it-works.png

-47.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)