Skip to content

Commit 2537344

Browse files
committed
unmask
1 parent 3de0343 commit 2537344

1 file changed

Lines changed: 19 additions & 17 deletions

File tree

.github/workflows/release.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,29 @@ jobs:
5151
push: true
5252
tags: greenjay/hydration-api-jobs:latest
5353

54-
- name: Get Swarmpit auth token
55-
id: swarmpit-auth
54+
- name: Redeploy on Swarmpit
5655
run: |
5756
TOKEN=$(curl -s -X POST "${{ secrets.SWARMPIT_URL }}/api/tokens" \
5857
-H "Content-Type: application/json" \
5958
-d '{"username":"${{ secrets.SWARMPIT_USER }}","password":"${{ secrets.SWARMPIT_PASSWORD }}"}' \
6059
| jq -r '.token')
61-
echo "token=$TOKEN" >> $GITHUB_OUTPUT
6260
63-
- name: Redeploy app service
64-
run: |
65-
SERVICE_ID=$(curl -s "${{ secrets.SWARMPIT_URL }}/api/services" \
66-
-H "Authorization: Bearer ${{ steps.swarmpit-auth.outputs.token }}" \
67-
| jq -r '.[] | select(.name == "hydration-api_app") | .id')
68-
curl -s -X POST "${{ secrets.SWARMPIT_URL }}/api/services/$SERVICE_ID/redeploy" \
69-
-H "Authorization: Bearer ${{ steps.swarmpit-auth.outputs.token }}"
61+
if [ -z "$TOKEN" ] || [ "$TOKEN" = "null" ]; then
62+
echo "Failed to get Swarmpit token"
63+
exit 1
64+
fi
7065
71-
- name: Redeploy jobs service
72-
run: |
73-
SERVICE_ID=$(curl -s "${{ secrets.SWARMPIT_URL }}/api/services" \
74-
-H "Authorization: Bearer ${{ steps.swarmpit-auth.outputs.token }}" \
75-
| jq -r '.[] | select(.name == "hydration-api_jobs") | .id')
76-
curl -s -X POST "${{ secrets.SWARMPIT_URL }}/api/services/$SERVICE_ID/redeploy" \
77-
-H "Authorization: Bearer ${{ steps.swarmpit-auth.outputs.token }}"
66+
SERVICES=$(curl -s "${{ secrets.SWARMPIT_URL }}/api/services" \
67+
-H "Authorization: Bearer $TOKEN")
68+
69+
for SERVICE in "hydration-api_app" "hydration-api_jobs"; do
70+
SERVICE_ID=$(echo "$SERVICES" | jq -r --arg name "$SERVICE" '.[] | select(.name == $name) | .id')
71+
if [ -z "$SERVICE_ID" ] || [ "$SERVICE_ID" = "null" ]; then
72+
echo "Service $SERVICE not found"
73+
exit 1
74+
fi
75+
echo "Redeploying $SERVICE ($SERVICE_ID)..."
76+
curl -s -X POST "${{ secrets.SWARMPIT_URL }}/api/services/$SERVICE_ID/redeploy" \
77+
-H "Authorization: Bearer $TOKEN"
78+
echo "Done"
79+
done

0 commit comments

Comments
 (0)