forked from clouddrove/github-shared-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (108 loc) · 3.76 KB
/
Copy pathaws-remote-ssh-command.yml
File metadata and controls
111 lines (108 loc) · 3.76 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
---
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."
required: false
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
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: false
type: string
slack_footer:
description: "Additional information or context often placed at the bottom of a message in Slack"
required: false
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 Repository
uses: actions/checkout@v7
- name: 🔐 Executing remote SSH commands using SSH key
uses: appleboy/ssh-action@v1.2.5
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_SSH_KEY }}
port: ${{ inputs.port }}
envs: ${{ inputs.envs }}
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: ${{ inputs.slack_message }}
SLACK_ICON: ${{ inputs.slack_icon }}
SLACK_USERNAME: ${{ inputs.slack_username }}
SLACK_FOOTER: ${{ inputs.slack_footer }}
SLACK_COLOR: ${{ job.status }}
slack-notification: ${{ inputs.slack-notification }}
...