mirror of
https://github.com/JuliusFreudenberger/portainer-stack-git-redeploy-action.git
synced 2024-11-23 19:34:39 +01:00
Improve logging
This commit is contained in:
parent
646000f132
commit
63d9c75bc2
2 changed files with 8 additions and 4 deletions
6
dist/index.js
vendored
6
dist/index.js
vendored
|
@ -2819,6 +2819,8 @@ var __webpack_exports__ = {};
|
||||||
(() => {
|
(() => {
|
||||||
const core = __nccwpck_require__(186)
|
const core = __nccwpck_require__(186)
|
||||||
|
|
||||||
|
console.log('Preparing stack deployment')
|
||||||
|
|
||||||
let portainerUrl = core.getInput("portainerUrl")
|
let portainerUrl = core.getInput("portainerUrl")
|
||||||
const accessToken = core.getInput("accessToken")
|
const accessToken = core.getInput("accessToken")
|
||||||
const stackId = parseInt(core.getInput("stackId"))
|
const stackId = parseInt(core.getInput("stackId"))
|
||||||
|
@ -2853,14 +2855,13 @@ const postDataObject = {
|
||||||
pullImage: true,
|
pullImage: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
console.dir(environmentVariables)
|
|
||||||
if (environmentVariables !== undefined && environmentVariables !== "") {
|
if (environmentVariables !== undefined && environmentVariables !== "") {
|
||||||
postDataObject.env = JSON.parse(environmentVariables)
|
postDataObject.env = JSON.parse(environmentVariables)
|
||||||
}
|
}
|
||||||
|
|
||||||
const postData = JSON.stringify(postDataObject)
|
const postData = JSON.stringify(postDataObject)
|
||||||
|
|
||||||
console.dir(postData)
|
console.log(`Deploying stack ${stackId} on portainer host ${portainerUrl} ${postDataObject.env ? 'With environment variables ' + JSON.stringify(postDataObject.env) : 'clearing all environment variables.'}`)
|
||||||
|
|
||||||
const req = client.request(`${portainerUrl}/api/stacks/${stackId}/git/redeploy` + (isNaN(endpointId) ? "" : `?endpointId=${endpointId}`), {
|
const req = client.request(`${portainerUrl}/api/stacks/${stackId}/git/redeploy` + (isNaN(endpointId) ? "" : `?endpointId=${endpointId}`), {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
|
@ -2874,6 +2875,7 @@ const req = client.request(`${portainerUrl}/api/stacks/${stackId}/git/redeploy`
|
||||||
core.setFailed(res.statusMessage)
|
core.setFailed(res.statusMessage)
|
||||||
process.exit(2)
|
process.exit(2)
|
||||||
}
|
}
|
||||||
|
console.log('Stack deployed successfully')
|
||||||
})
|
})
|
||||||
.on("error", (error) => {
|
.on("error", (error) => {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
|
|
6
index.js
6
index.js
|
@ -1,5 +1,7 @@
|
||||||
const core = require("@actions/core")
|
const core = require("@actions/core")
|
||||||
|
|
||||||
|
console.log('Preparing stack deployment')
|
||||||
|
|
||||||
let portainerUrl = core.getInput("portainerUrl")
|
let portainerUrl = core.getInput("portainerUrl")
|
||||||
const accessToken = core.getInput("accessToken")
|
const accessToken = core.getInput("accessToken")
|
||||||
const stackId = parseInt(core.getInput("stackId"))
|
const stackId = parseInt(core.getInput("stackId"))
|
||||||
|
@ -34,14 +36,13 @@ const postDataObject = {
|
||||||
pullImage: true,
|
pullImage: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
console.dir(environmentVariables)
|
|
||||||
if (environmentVariables !== undefined && environmentVariables !== "") {
|
if (environmentVariables !== undefined && environmentVariables !== "") {
|
||||||
postDataObject.env = JSON.parse(environmentVariables)
|
postDataObject.env = JSON.parse(environmentVariables)
|
||||||
}
|
}
|
||||||
|
|
||||||
const postData = JSON.stringify(postDataObject)
|
const postData = JSON.stringify(postDataObject)
|
||||||
|
|
||||||
console.dir(postData)
|
console.log(`Deploying stack ${stackId} on portainer host ${portainerUrl} ${postDataObject.env ? 'With environment variables ' + JSON.stringify(postDataObject.env) : 'clearing all environment variables.'}`)
|
||||||
|
|
||||||
const req = client.request(`${portainerUrl}/api/stacks/${stackId}/git/redeploy` + (isNaN(endpointId) ? "" : `?endpointId=${endpointId}`), {
|
const req = client.request(`${portainerUrl}/api/stacks/${stackId}/git/redeploy` + (isNaN(endpointId) ? "" : `?endpointId=${endpointId}`), {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
|
@ -55,6 +56,7 @@ const req = client.request(`${portainerUrl}/api/stacks/${stackId}/git/redeploy`
|
||||||
core.setFailed(res.statusMessage)
|
core.setFailed(res.statusMessage)
|
||||||
process.exit(2)
|
process.exit(2)
|
||||||
}
|
}
|
||||||
|
console.log('Stack deployed successfully')
|
||||||
})
|
})
|
||||||
.on("error", (error) => {
|
.on("error", (error) => {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
|
|
Loading…
Reference in a new issue