Skip to content

Commit a855474

Browse files
Merge pull request #222 from canonical/refresh-or-deploy
feat: Refresh or deploy charm
2 parents 572feb3 + 9bea60b commit a855474

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

.github/workflows/deploy.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,13 @@ jobs:
121121
- name: Deploy Application to staging
122122
run: |
123123
export JUJU_MODEL=admin/stg-cs-canonical-com
124-
juju refresh cs-canonical-com --path ./cs-canonical-com_ubuntu-22.04-amd64.charm --resource flask-app-image=${{ needs.publish-image.outputs.image_url }}
124+
if juju status --relations | grep -q "cs-canonical-com"; then
125+
echo "Application 'cs-canonical-com' exists. Running juju refresh..."
126+
juju refresh cs-canonical-com --path ./*.charm --resource flask-app-image=${{ needs.publish-image.outputs.image_url }}
127+
else
128+
echo "Application 'cs-canonical-com' not found. Running juju deploy..."
129+
juju deploy ./*.charm cs-canonical-com --resource flask-app-image=${{ needs.publish-image.outputs.image_url }}
130+
fi
125131
juju wait-for application cs-canonical-com --query='name=="cs-canonical-com" && (status=="active" || status=="idle")'
126132
127133
deploy-production:
@@ -159,5 +165,11 @@ jobs:
159165
- name: Deploy Application to production
160166
run: |
161167
export JUJU_MODEL=admin/prod-cs-canonical-com
162-
juju refresh cs-canonical-com --path ./cs-canonical-com_ubuntu-22.04-amd64.charm --resource flask-app-image=${{ needs.publish-image.outputs.image_url }}
168+
if juju status --relations | grep -q "cs-canonical-com"; then
169+
echo "Application 'cs-canonical-com' exists. Running juju refresh..."
170+
juju refresh cs-canonical-com --path ./*.charm --resource flask-app-image=${{ needs.publish-image.outputs.image_url }}
171+
else
172+
echo "Application 'cs-canonical-com' not found. Running juju deploy..."
173+
juju deploy ./*.charm cs-canonical-com --resource flask-app-image=${{ needs.publish-image.outputs.image_url }}
174+
fi
163175
juju wait-for application cs-canonical-com --query='name=="cs-canonical-com" && (status=="active" || status=="idle")'

0 commit comments

Comments
 (0)