-
Notifications
You must be signed in to change notification settings - Fork 2
226 lines (206 loc) · 7.27 KB
/
RemoteSSHCommand.yml
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
---
name: "remote ssh command"
on:
workflow_call:
inputs:
port:
description: "Specify the SSH port number for the remote connection."
type: string
default: "22"
sync:
description: "Enable synchronous execution when dealing with multiple hosts."
type: string
required: false
timeout:
description: "Timeout duration for establishing an SSH connection to the host."
type: string
default: "30s"
required: false
command_timeout:
description: "Timeout duration for executing SSH commands."
type: string
default: "10m"
required: false
script:
description: "Specify the commands to be executed on the remote host."
type: string
script_stop:
description: "Stop the script after the first failure."
type: string
default: false
envs:
description: "Specify environment variables to be passed to the remote shell script."
type: string
debug:
description: "Enable debug mode for additional logging."
type: string
default: false
allenvs:
description: "Pass all environment variables to the remote shell script."
type: string
default: false
request_pty:
description: "Request a pseudo-terminal from the server."
type: string
default: false
SLACK_USERNAME:
description: "It is the name displayed to others in Message on Slack channel"
required: true
type: string
SLACK_FOOTER:
description: "Additional information or context often placed at the bottom of a message in Slack"
required: true
type: string
SLACK_ICON:
description: "The visual representation associated with a user or a group on Slack"
required: false
type: string
SLACK_MESSAGE:
description: "The content or information you want to share on Slack, which is a messaging platform."
required: false
type: string
SLACK_COLOR:
description: "The visual styling applied to elements within a message or interface on Slack."
required: false
type: string
slack-notification:
description: "sending a brief message to a designated Slack channel."
default: false
type: string
secrets:
PRIVATE_SSH_KEY:
description: "Private SSH Key for secure communication with the server."
required: true
HOST:
description: "Public IP address of the server for remote access."
required: true
USERNAME:
description: "Username for authentication on the remote system or service."
required: true
SLACK_WEBHOOK_URL:
description: Specify Slack Incoming Webhook URL
required: false
jobs:
ssh-action:
runs-on: ubuntu-latest
steps:
- name: Checkout git repo
uses: actions/checkout@v4
- name: executing remote ssh commands using ssh key
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_SSH_KEY }}
port: ${{ inputs.port }}
envs: ${{ inputs.envs }}
---
name: "remote ssh command"
on:
workflow_call:
inputs:
port:
description: "Specify the SSH port number for the remote connection."
type: string
default: "22"
sync:
description: "Enable synchronous execution when dealing with multiple hosts."
type: string
required: false
timeout:
description: "Timeout duration for establishing an SSH connection to the host."
type: string
default: "30s"
required: false
command_timeout:
description: "Timeout duration for executing SSH commands."
type: string
default: "10m"
required: false
script:
description: "Specify the commands to be executed on the remote host."
type: string
script_stop:
description: "Stop the script after the first failure."
type: string
default: false
envs:
description: "Specify environment variables to be passed to the remote shell script."
type: string
envs_format:
description: "Flexible configuration for transferring environment values."
type: string
debug:
description: "Enable debug mode for additional logging."
type: string
default: false
request_pty:
description: "Request a pseudo-terminal from the server."
type: string
default: false
slack_username:
description: "It is the name displayed to others in Message on Slack channel"
required: true
type: string
slack_footer:
description: "Additional information or context often placed at the bottom of a message in Slack"
required: true
type: string
slack_icon:
description: "The visual representation associated with a user or a group on Slack"
required: false
type: string
slack_message:
description: "The content or information you want to share on Slack, which is a messaging platform."
required: false
type: string
slack_color:
description: "The visual styling applied to elements within a message or interface on Slack."
required: false
type: string
slack-notification:
description: "sending a brief message to a designated Slack channel."
default: false
type: string
secrets:
PRIVATE_SSH_KEY:
description: "Private SSH Key for secure communication with the server."
required: true
HOST:
description: "Public IP address of the server for remote access."
required: true
USERNAME:
description: "Username for authentication on the remote system or service."
required: true
SLACK_WEBHOOK_URL:
description: Specify Slack Incoming Webhook URL
required: false
jobs:
ssh-action:
runs-on: ubuntu-latest
steps:
- name: Checkout git repo
uses: actions/checkout@v4
- name: executing remote ssh commands using ssh key
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_SSH_KEY }}
port: ${{ inputs.port }}
envs: ${{ inputs.envs }}
debug: ${{ inputs.dubug }}
request_pty: ${{ inputs.request_pty }}
script: |
${{ inputs.script }}
- name: slack notification
if: ${{ inputs.slack-notification == 'true' && always() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_MESSAGE: ${{ job.status }}
SLACK_ICON: ${{ inputs.slack_icon }}
SLACK_USERNAME: ${{ inputs.slack_username }}
SLACK_FOOTER: ${{ inputs.slack_footer }}
SLACK_COLOR: ${{ job.status }}
slack-notification: ${{ inputs.slack-notification }}