-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
72 lines (64 loc) · 2.18 KB
/
action.yml
File metadata and controls
72 lines (64 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: 'Deploy to Dokploy'
description: 'Triggers a Dokploy deployment with a new Docker image'
inputs:
base_url:
description: 'Dokploy base URL (e.g., https://dokploy.example.com)'
required: true
token:
description: 'Dokploy API authentication token'
required: true
application_id:
description: 'Dokploy application ID (retrieve from /api/project.all)'
required: true
image:
description: 'Docker image to deploy'
required: true
branding:
icon: activity
color: blue
runs:
using: 'composite'
steps:
- name: Update Dokploy application image
shell: bash
env:
DOKPLOY_URL: ${{ inputs.base_url }}
DOKPLOY_APP_ID: ${{ inputs.application_id }}
DOKPLOY_TOKEN: ${{ inputs.token }}
DOKPLOY_IMAGE: ${{ inputs.image }}
run: |
response=$(curl -X 'POST' \
"$DOKPLOY_URL/api/application.update" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "x-api-key: $DOKPLOY_TOKEN" \
-d "{\"applicationId\": \"$DOKPLOY_APP_ID\", \"dockerImage\": \"$DOKPLOY_IMAGE\"}" \
-w "\n%{http_code}" -s)
http_code=$(echo "$response" | tail -n 1)
body=$(echo "$response" | head -n -1)
if [ "$http_code" -ne 200 ]; then
echo "::error::Deployment failed with status code: $http_code"
fi
if [ "$body" != "true" ]; then
echo "::error::Deployment failed: expected 'true' but got '$body'"
fi
- name: 'Dokploy Deployment'
shell: bash
env:
DOKPLOY_URL: ${{ inputs.base_url }}
DOKPLOY_APP_ID: ${{ inputs.application_id }}
DOKPLOY_TOKEN: ${{ inputs.token }}
run: |
response=$(curl -X 'POST' \
"$DOKPLOY_URL/api/application.deploy" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $DOKPLOY_TOKEN" \
-d "{\"applicationId\": \"$DOKPLOY_APP_ID\"}" \
-w "%{http_code}" \
-o /dev/null \
-s)
if [ "$response" -ne 200 ]; then
echo "::error::Deployment failed with status code: $response"
exit 1
fi