-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
96 lines (86 loc) · 2.74 KB
/
action.yaml
File metadata and controls
96 lines (86 loc) · 2.74 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Deploy via Uncloud
description: Deploy Docker images via Uncloud.
author: thatskyapplication
branding:
icon: cloud
color: black
inputs:
image-tag:
description: Docker image tag to deploy.
required: true
compose-files:
description: One or more Compose files (space-separated). Required unless `push-only` is `true`.
required: false
uncloud-profile:
description: One or more profiles to enable (space-separated).
required: false
ssh-private-key:
description: SSH private key for server access.
required: true
server-user:
description: SSH username for the server.
required: true
server-host:
description: Server hostname.
required: true
recreate:
description: Recreate containers even if their configuration and image haven't changed.
required: false
default: "false"
version:
description: Version to use for the Uncloud CLI.
required: false
push-only:
description: Does not deploy; only pushes the image to the server.
required: false
default: "false"
runs:
using: composite
steps:
- name: Install Uncloud CLI
shell: bash
env:
VERSION: ${{ inputs.version }}
run: curl --fail --show-error --silent https://get.uncloud.run/install.sh | sh
- name: Set up SSH agent
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ inputs.ssh-private-key }}
- name: Add server to known hosts
shell: bash
env:
SERVER_HOST: ${{ inputs.server-host }}
run: ssh-keyscan -H "$SERVER_HOST" >> ~/.ssh/known_hosts
- name: Push image to server
shell: bash
env:
IMAGE_TAG: ${{ inputs.image-tag }}
SERVER_USER: ${{ inputs.server-user }}
SERVER_HOST: ${{ inputs.server-host }}
run: uc image push "$IMAGE_TAG" --connect "$SERVER_USER@$SERVER_HOST"
- name: Deploy via Uncloud
if: inputs.push-only != 'true'
shell: bash
env:
SERVER_USER: ${{ inputs.server-user }}
SERVER_HOST: ${{ inputs.server-host }}
COMPOSE_FILES: ${{ inputs.compose-files }}
UNCLOUD_PROFILE: ${{ inputs.uncloud-profile }}
RECREATE: ${{ inputs.recreate }}
run: |
if [ -z "$COMPOSE_FILES" ]; then
echo "::error::No compose files detected. At least one is required when deploying."
exit 1
fi
DEPLOY_ARGS=(--connect "$SERVER_USER@$SERVER_HOST")
for file in $COMPOSE_FILES; do
DEPLOY_ARGS+=(--file "$file")
done
if [ -n "$UNCLOUD_PROFILE" ]; then
DEPLOY_ARGS+=(--profile "$UNCLOUD_PROFILE")
fi
if [ "$RECREATE" = "true" ]; then
DEPLOY_ARGS+=(--recreate)
fi
DEPLOY_ARGS+=(--yes)
uc deploy "${DEPLOY_ARGS[@]}"