.github/workflows/main.yaml #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |