forked from AdminTurnedDevOps/GoWebAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstep-template.json
More file actions
83 lines (83 loc) · 4.05 KB
/
step-template.json
File metadata and controls
83 lines (83 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{
"Id": "3aa47b93-e859-4a8a-946d-13921f3c7197",
"Name": "Docker - Build and Push an Image to Dockerhub",
"Description": "Creates and pushes an Docker Image.\n\n- Requires the Docker infrastructure.",
"ActionType": "Octopus.Script",
"Version": 1,
"CommunityActionTemplateId": null,
"Packages": [],
"Properties": {
"Octopus.Action.Script.ScriptBody": "# Get the parameters.\n$appLocation = $OctopusParameters['DockerfileLocation']\n$dockerFile = $OctopusParameters['DockerFile']\n$imageName = $OctopusParameters['ImageName']\n$tag = $OctopusParameters['ImageTag']\n$dockerUsername = $OctopusParameters['DockerUsername']\n$dockerPassword = $OctopusParameters['DockerPassword']\n\n# Check the parameters.\nif (-NOT $dockerUsername) { throw \"You must enter a value for 'Username'.\" }\nif (-NOT $dockerPassword) { throw \"You must enter a value for 'Password'.\" }\nif (-NOT $imageName) { throw \"You must enter a value for 'Image Name'.\" }\nif (-NOT $tag) { throw \"You must enter a value for 'Image Tag'.\" }\nif (-NOT $appLocation) { throw \"You must enter a value for 'Dockerfile Location'.\" }\n\n# If the Dockerfile parameter is not empty, save it to the file.\nif ($dockerFile) \n{\n Write-Output 'Saving the Dockerfile'\n $path = Join-Path $appLocation 'Dockerfile'\n Set-Content -Path $path -Value $dockerFile -Force\n}\n\n# If the tag parameter is empty, set it as latest.\nif (-NOT $tag) \n{\n $tag = 'latest'\n}\n\n# Prepare the final image name with the tag.\n$imageName += ':' + $tag\n\n# Create the docker image\nWrite-Output 'Building the Docker Image'\nsudo docker build -t $imageName .\n\n# Upload to DockerHub\nWrite-Output 'Pushing the Docker Image to DockerHub'\nsudo docker login --username=$dockerUsername --password=$dockerPassword\nsudo docker push $imageName",
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptSource": "Inline"
},
"Parameters": [
{
"Id": "a3d56a5f-4a3e-4eec-ac75-b27d96a4206a",
"Name": "DockerUsername",
"Label": "Docker Username",
"HelpText": "The username used to login to DockerHub",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "3022543d-41ec-4b5a-9b9e-5072d33522db",
"Name": "DockerPassword",
"Label": "Docker Password",
"HelpText": "The password used to login to DockerHub",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "Sensitive"
}
},
{
"Id": "4c0e2b19-3307-49c0-a202-4baf2a066558",
"Name": "DockerfileLocation",
"Label": "Dockerfile Location",
"HelpText": "Location on the deployment target where the Dockerfile should be saved.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "aaee54ac-2470-4d38-90b6-799f0b9aa4d8",
"Name": "DockerFile",
"Label": "Dockerfile",
"HelpText": "The Dockerfile definition. If the Dockerfile is part of the package leave it blank",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "MultiLineText"
}
},
{
"Id": "9e8d0131-26a0-4c51-bb70-758eed70f252",
"Name": "ImageName",
"Label": "Image Name",
"HelpText": "The image name in DockerHub",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "25df2def-98ab-45b4-8805-670aa08b297e",
"Name": "ImageTag",
"Label": "Image Tag",
"HelpText": "The image tag. Leave it blank for 'latest'",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
}
],
"$Meta": {
"ExportedAt": "2020-09-25T20:37:57.314Z",
"OctopusVersion": "2020.4.0",
"Type": "ActionTemplate"
},
"LastModifiedBy": "Your GitHub Username",
"Category": "other"
}