forked from cmliu/socks5-for-serv00
-
Notifications
You must be signed in to change notification settings - Fork 0
38 lines (32 loc) · 1.34 KB
/
check_cron.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
35
36
37
38
name: Execute SSH Commands
on:
workflow_dispatch: # 手动触发工作流
schedule:
- cron: "30 0,13 * * *" # 每天 北京时间 早8点30分 晚9点30分 各运行一次
jobs:
execute-commands:
runs-on: ubuntu-latest
steps:
- name: Set up SSHPass
run: sudo apt-get update && sudo apt-get install -y sshpass
- name: Get ACCOUNTS_JSON
id: get-accounts
run: |
echo "$ACCOUNTS_JSON" > accounts.json
env:
ACCOUNTS_JSON: ${{ secrets.ACCOUNTS_JSON }}
# 从 GitHub Secrets 获取 ACCOUNTS_JSON 变量,并保存到文件 accounts.json
- name: Generate SSH Commands
id: generate-ssh-commands
run: |
echo "#!/bin/bash" > sshpass.sh
while IFS= read -r account; do
username=$(echo "$account" | jq -r '.username')
password=$(echo "$account" | jq -r '.password')
ssh=$(echo "$account" | jq -r '.ssh')
echo "echo \"Executing for $username@$ssh\"" >> sshpass.sh
echo "sshpass -p '$password' ssh -o StrictHostKeyChecking=no '$username@$ssh' 'bash <(curl -s https://raw.githubusercontent.com/cmliu/socks5-for-serv00/main/check_cron.sh)'" >> sshpass.sh
done < <(jq -c '.[]' accounts.json)
chmod +x sshpass.sh
- name: Execute SSH Commands
run: ./sshpass.sh