Skip to content

Commit

Permalink
Make protocol configurable (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwi authored Jun 17, 2024
1 parent e0781e7 commit a81a50d
Show file tree
Hide file tree
Showing 2 changed files with 11 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 @@ -12,6 +12,10 @@ inputs:
required: true
description: Portainer Domain
default: "deploy.signalwire.cloud"
PORTAINER_DOMAIN_PROTOCOL:
required: true
description: Portainer Protocol
default: "http"
outputs:
DEPLOYED_DATE:
description: 'date and time that image was deployed'
Expand All @@ -29,14 +33,14 @@ runs:
id: deploy
shell: bash
run: |
curl -s -H "X-API-Key: ${{env.PORTAINER_API_KEY}}" http://${{inputs.PORTAINER_DOMAIN}}/api/endpoints/${{env.ENDPOINT_ID}}/docker/services/${{ inputs.STACK_NAME }} > service.spec.json
curl -s -H "X-API-Key: ${{env.PORTAINER_API_KEY}}" ${{inputs.PORTAINER_DOMAIN_PROTOCOL}}://${{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}}" -H "Content-Type: application/json" http://${{inputs.PORTAINER_DOMAIN}}/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}}" -H "Content-Type: application/json" ${{inputs.PORTAINER_DOMAIN_PROTOCOL}}://${{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
5 changes: 5 additions & 0 deletions .github/workflows/cd-swarm-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ on:
type: string
description: Portainer Domain
default: deploy.signalwire.cloud
PORTAINER_DOMAIN_PROTOCOL:
required: true
type: string
description: Portainer Protocol
default: http
secrets:
ENDPOINT_ID:
required: false
Expand Down

0 comments on commit a81a50d

Please sign in to comment.