Skip to content

Commit

Permalink
Merge pull request #244 from signalwire/fix/swarm-endpoint
Browse files Browse the repository at this point in the history
fix portainer domain
  • Loading branch information
lucasmellos authored Mar 22, 2024
2 parents f87d37a + 04ac9b2 commit 75d23d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/actions/swarm-deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
6 changes: 6 additions & 0 deletions .github/workflows/cd-swarm-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 75d23d2

Please sign in to comment.