-
Notifications
You must be signed in to change notification settings - Fork 299
34 lines (30 loc) · 1.13 KB
/
main.yaml
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
name: serv00 login
on:
schedule:
- cron: '0 10 */30 * *' # 每 30 天的上午 10 点运行
workflow_dispatch:
jobs:
ssh-execution:
runs-on: ubuntu-latest
steps:
- name: Install SSH client
run: sudo apt-get update && sudo apt-get install -y openssh-client
- name: SSH and Run Script
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script_stop: true
script: |
echo "Starting SSH script execution..."
IP=$(echo "$SSH_CLIENT" | awk '{ print $1 }')
time=$(TZ='Asia/Shanghai' date +"%Y-%m-%d %H:%M:%S")
user=$(whoami)
TITLE="serv00 服务器登录提醒"
CONTENT="用户:${user},登录了 serv00 服务器<br/>登录 IP:${IP}<br/>登录时间:${time}"
URL="https://www.pushplus.plus/send/"
TOKEN="${{ secrets.PUSHPLUS_TOKEN }}"
response=$(curl -s -X POST -d "token=$TOKEN&title=$TITLE&content=$CONTENT" "$URL")
echo "$response"
exit