From 04ac9b209fda408ca4da7a7bc8594de24470c08f Mon Sep 17 00:00:00 2001 From: Lucas Mellos Carlos Date: Fri, 22 Mar 2024 12:10:52 -0300 Subject: [PATCH] fix portainer domain --- .github/actions/swarm-deploy/action.yml | 8 ++++++-- .github/workflows/cd-swarm-deploy.yml | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/actions/swarm-deploy/action.yml b/.github/actions/swarm-deploy/action.yml index a312297b..eff596ce 100644 --- a/.github/actions/swarm-deploy/action.yml +++ b/.github/actions/swarm-deploy/action.yml @@ -8,6 +8,10 @@ inputs: IMAGE_TAG: required: true description: image tag to deploy to + PORTAINER_DOMAIN: + required: true + description: Portainer Domain + default: "deploy.signalwire.cloud" outputs: DEPLOYED_DATE: description: 'date and time that image was deployed' @@ -22,14 +26,14 @@ runs: id: deploy shell: bash run: | - curl -s -H "X-API-Key: ${{env.PORTAINER_API_KEY}}" https://deploy.signalwire.cloud/api/endpoints/${{env.ENDPOINT_ID}}/docker/services/${{ inputs.STACK_NAME }} > service.spec.json + curl -s -H "X-API-Key: ${{env.PORTAINER_API_KEY}}" https://${{inputs.PORTAINER_DOMAIN}}/api/endpoints/${{env.ENDPOINT_ID}}/docker/services/${{ inputs.STACK_NAME }} > service.spec.json version=$(jq '.Version.Index' service.spec.json) previousimg=$(jq '.Spec.TaskTemplate.ContainerSpec.Image' -r service.spec.json) jq '.Spec.TaskTemplate.ContainerSpec.Image="${{ inputs.IMAGE_TAG}}" | .Spec' service.spec.json > update.spec.json - curl -s -X POST -H "X-API-Key: ${{env.PORTAINER_API_KEY}}" https://deploy.signalwire.cloud/api/endpoints/${{env.ENDPOINT_ID}}/docker/services/${{ inputs.STACK_NAME }}/update?version=$version -d @update.spec.json + curl -s -X POST -H "X-API-Key: ${{env.PORTAINER_API_KEY}}" https://${{inputs.PORTAINER_DOMAIN}}/api/endpoints/${{env.ENDPOINT_ID}}/docker/services/${{ inputs.STACK_NAME }}/update?version=$version -d @update.spec.json echo PREVIOUS_IMAGE=$previousimg >> $GITHUB_OUTPUT echo DEPLOYED_DATE=$(date -u) >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/.github/workflows/cd-swarm-deploy.yml b/.github/workflows/cd-swarm-deploy.yml index 4badbac1..47f7bd83 100644 --- a/.github/workflows/cd-swarm-deploy.yml +++ b/.github/workflows/cd-swarm-deploy.yml @@ -37,6 +37,11 @@ on: type: string description: Another option to set ENDPOINT_ID. default: '' + PORTAINER_DOMAIN: + required: true + type: string + description: Portainer Domain + default: deploy.signalwire.cloud secrets: ENDPOINT_ID: required: false @@ -102,6 +107,7 @@ jobs: with: STACK_NAME: ${{ inputs.STACK_NAME }} IMAGE_TAG: ${{ inputs.IMAGE_TAG }} + PORTAINER_DOMAIN: ${{ inputs.PORTAINER_DOMAIN }} - uses: ./actions/.github/actions/slack if: always()