Skip to content

Commit df788ed

Browse files
committed
Allow 'restarting' (recreating) in addition to rollout
1 parent 9d5a4cd commit df788ed

File tree

6 files changed

+26
-16
lines changed

6 files changed

+26
-16
lines changed

action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ inputs:
99
description: "The tag used for re-deploy"
1010
required: false
1111
default: "develop"
12+
strategy:
13+
description: "The strategy to use for this deployment"
14+
required: false
15+
default: "rollout"
16+
type: choice
17+
options:
18+
- rollout
19+
- restart
1220
url:
1321
description: "The re-deployment service URL"
1422
required: true

autodeploy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ class AutoDeployApi {
2323
});
2424
}
2525

26-
redeployUrl(type, targets) {
26+
redeployUrl(type, strategy, targets) {
2727
const encodedTargets = targets
2828
.split(",")
2929
.map((target) => encodeURIComponent(target.trim()))
3030
.join(",");
31-
return `${this.url}/${type}/${encodedTargets}/rollout`;
31+
return `${this.url}/${type}/${encodedTargets}/${strategy}`;
3232
}
3333

34-
async redeploy(type, targets, tag) {
34+
async redeploy(type, strategy, targets, tag) {
3535
const response = await this.client.postJson(
36-
this.redeployUrl(type, targets),
36+
this.redeployUrl(type, strategy, targets),
3737
{ push_data: { tag } }
3838
);
3939

dist/index.js

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@ async function run() {
66
try {
77
const pods = core.getInput("pods");
88
const images = core.getInput("images");
9+
const strategy = core.getInput("strategy")
910
const tag = core.getInput("tag") || "develop";
1011
const url = core.getInput("url", { required: true });
1112
const token = core.getInput("token", { required: true });
1213
const timeout = parseInt(core.getInput("timeout") || 60000);
1314

14-
core.info(`Re-deploying pods ${pods} for tag ${tag}`);
15+
core.info(`Re-deploying pods ${pods} for tag ${tag} with a ${strategy} strategy`);
1516
const api = new AutoDeployApi(url, token, timeout);
1617

1718
if (pods) {
18-
status = await api.redeploy("services", pods, tag);
19+
status = await api.redeploy("services", strategy, pods, tag);
1920
}
2021
if (images) {
21-
status = await api.redeploy("images", images, tag);
22+
status = await api.redeploy("images", strategy, images, tag);
2223
}
2324
if(!pods && !images) {
2425
throw new Error("Specify either the pods or container image for which you want to trigger a redeploy.");

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "autodeploy-action",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "An action to automatically trigger a re-deployment of Kubernetes pods",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)