mirror of
https://github.com/JuliusFreudenberger/portainer-stack-git-redeploy-action.git
synced 2025-04-20 13:28:02 +02:00
Compare commits
No commits in common. "main" and "v1.0.0" have entirely different histories.
4 changed files with 5 additions and 27 deletions
|
@ -21,10 +21,6 @@ This is a fork of [wirgen/portainer-stack-redeploy-action](https://github.com/wi
|
||||||
|
|
||||||
ID of endpoint (environment). Required if your stack is not in local environment
|
ID of endpoint (environment). Required if your stack is not in local environment
|
||||||
|
|
||||||
### `repositoryAuthentication`
|
|
||||||
|
|
||||||
Use stored credentials to pull docker-compose.yaml from git repository. When credentials are stored, but this is not set to `true`, the action will fail
|
|
||||||
|
|
||||||
### `environment`
|
### `environment`
|
||||||
|
|
||||||
Environment variables to set on the stack. When omitted, all existing variables will be cleared from the stack. Must be input as a JSON String; one array of objects each with the keys `name` and `value`
|
Environment variables to set on the stack. When omitted, all existing variables will be cleared from the stack. Must be input as a JSON String; one array of objects each with the keys `name` and `value`
|
||||||
|
|
|
@ -16,16 +16,12 @@ inputs:
|
||||||
description: 'Endpoint ID'
|
description: 'Endpoint ID'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
repositoryAuthentication:
|
|
||||||
description: 'Use stored credentials to pull docker-compose.yaml from git repository'
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
environment:
|
environment:
|
||||||
description: 'Environment variables'
|
description: 'Environment variables'
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node16'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
|
|
11
dist/index.js
vendored
11
dist/index.js
vendored
|
@ -2819,13 +2819,10 @@ 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"))
|
||||||
const endpointId = parseInt(core.getInput("endpointId"))
|
const endpointId = parseInt(core.getInput("endpointId"))
|
||||||
const repositoryAuthentication = core.getInput("repositoryAuthentication")
|
|
||||||
const environmentVariables = core.getInput("environment")
|
const environmentVariables = core.getInput("environment")
|
||||||
|
|
||||||
if (isNaN(stackId)) {
|
if (isNaN(stackId)) {
|
||||||
|
@ -2856,17 +2853,14 @@ const postDataObject = {
|
||||||
pullImage: true,
|
pullImage: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repositoryAuthentication === true || repositoryAuthentication === 'true') {
|
console.dir(environmentVariables)
|
||||||
postDataObject.repositoryAuthentication = true
|
|
||||||
}
|
|
||||||
|
|
||||||
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.log(`Deploying stack ${stackId} on portainer host ${portainerUrl} ${postDataObject.env ? 'With environment variables ' + JSON.stringify(postDataObject.env) : 'clearing all environment variables.'}`)
|
console.dir(postData)
|
||||||
|
|
||||||
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",
|
||||||
|
@ -2880,7 +2874,6 @@ 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)
|
||||||
|
|
11
index.js
11
index.js
|
@ -1,12 +1,9 @@
|
||||||
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"))
|
||||||
const endpointId = parseInt(core.getInput("endpointId"))
|
const endpointId = parseInt(core.getInput("endpointId"))
|
||||||
const repositoryAuthentication = core.getInput("repositoryAuthentication")
|
|
||||||
const environmentVariables = core.getInput("environment")
|
const environmentVariables = core.getInput("environment")
|
||||||
|
|
||||||
if (isNaN(stackId)) {
|
if (isNaN(stackId)) {
|
||||||
|
@ -37,17 +34,14 @@ const postDataObject = {
|
||||||
pullImage: true,
|
pullImage: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repositoryAuthentication === true || repositoryAuthentication === 'true') {
|
console.dir(environmentVariables)
|
||||||
postDataObject.repositoryAuthentication = true
|
|
||||||
}
|
|
||||||
|
|
||||||
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.log(`Deploying stack ${stackId} on portainer host ${portainerUrl} ${postDataObject.env ? 'With environment variables ' + JSON.stringify(postDataObject.env) : 'clearing all environment variables.'}`)
|
console.dir(postData)
|
||||||
|
|
||||||
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",
|
||||||
|
@ -61,7 +55,6 @@ 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…
Add table
Reference in a new issue