2024-10-27 12:05:32 +00:00
|
|
|
name: Clone Repository with Trojan-Go Proxy
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
clone_with_proxy:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2024-10-27 12:18:42 +00:00
|
|
|
|
|
|
|
- name: 🚀 打印测试密钥是否支持换行
|
|
|
|
env:
|
|
|
|
TROJAN_GO_CONFIG: ${{ secrets.TROJAN_GO_CONFIG }}
|
|
|
|
run: |
|
|
|
|
# 将密钥内容写入文件
|
|
|
|
echo "$TROJAN_GO_CONFIG" > test_config.json
|
|
|
|
|
|
|
|
# 打印文件内容,检查换行是否保留
|
|
|
|
echo "Testing multiline secret content:"
|
|
|
|
cat test_config.json
|
|
|
|
|
|
|
|
|
2024-10-27 12:05:32 +00:00
|
|
|
# 1. 安装 Trojan-Go 客户端
|
|
|
|
- name: 🚀 安装 Trojan-Go
|
|
|
|
run: |
|
|
|
|
# 下载 Trojan-Go 二进制文件
|
|
|
|
wget -O trojan-go.zip https://github.com/p4gefau1t/trojan-go/releases/latest/download/trojan-go-linux-amd64.zip
|
|
|
|
unzip trojan-go.zip -d trojan-go
|
|
|
|
sudo mv trojan-go/trojan-go /usr/local/bin/trojan-go
|
|
|
|
rm -rf trojan-go.zip trojan-go
|
|
|
|
|
|
|
|
# 2. 配置代理参数
|
|
|
|
- name: 🔧 配置 Trojan-Go 代理
|
|
|
|
run: |
|
2024-10-27 12:21:18 +00:00
|
|
|
# 将多行 JSON 配置内容从 Secrets 中写入 trojan-go-config.json 文件
|
|
|
|
echo "$TROJAN_GO_CONFIG" > trojan-go-config.json
|
|
|
|
env:
|
|
|
|
TROJAN_GO_CONFIG: ${{ secrets.TROJAN_GO_CONFIG }}
|
2024-10-27 12:05:32 +00:00
|
|
|
|
|
|
|
# 3. 启动 Trojan-Go 并检测代理是否可用
|
2024-10-27 12:11:13 +00:00
|
|
|
- name: 🔍 测试代理的连通性
|
2024-10-27 12:05:32 +00:00
|
|
|
run: |
|
|
|
|
nohup trojan-go -config trojan-go-config.json &
|
2024-10-27 12:11:13 +00:00
|
|
|
sleep 5 # 等待代理启动
|
|
|
|
|
|
|
|
# 使用 curl 测试代理连接指定站点
|
|
|
|
if curl -x socks5://127.0.0.1:1080 -s --max-time 10 https://example.com > /dev/null; then
|
|
|
|
echo "代理连接成功"
|
2024-10-27 12:05:32 +00:00
|
|
|
else
|
2024-10-27 12:11:13 +00:00
|
|
|
echo "代理连接失败,请检查配置" && exit 1
|
2024-10-27 12:05:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 4. 使用代理克隆仓库
|
|
|
|
- name: 🚀 使用代理克隆仓库
|
|
|
|
env:
|
|
|
|
REPO_URL: https://github.com/coolsnowwolf/lede
|
|
|
|
REPO_BRANCH: master
|
|
|
|
ALL_PROXY: "socks5://127.0.0.1:1080"
|
|
|
|
http_proxy: "socks5://127.0.0.1:1080"
|
|
|
|
https_proxy: "socks5://127.0.0.1:1080"
|
|
|
|
run: |
|
2024-10-27 12:21:18 +00:00
|
|
|
echo "Checking ALL_PROXY: $ALL_PROXY"
|
2024-10-27 12:05:32 +00:00
|
|
|
git clone --depth 1 $REPO_URL -b $REPO_BRANCH
|
2024-10-27 12:29:10 +00:00
|
|
|
|
|
|
|
# 1. 不使用代理的步骤
|
|
|
|
- name: 🌐 Step without Proxy
|
|
|
|
run: |
|
|
|
|
echo "Checking if ALL_PROXY is set (no proxy expected):"
|
|
|
|
if [ -z "$ALL_PROXY" ]; then
|
|
|
|
echo "No ALL_PROXY set. Not using proxy."
|
|
|
|
else
|
|
|
|
echo "ALL_PROXY is set to $ALL_PROXY. Proxy in use."
|
|
|
|
fi
|
|
|
|
echo "Attempting to access example.com without proxy..."
|
|
|
|
curl -s --max-time 10 https://example.com || echo "Request failed, likely due to no proxy."
|
|
|
|
|
|
|
|
# 2. 使用代理的步骤
|
|
|
|
- name: 🌐 Step with Proxy
|
|
|
|
env:
|
|
|
|
ALL_PROXY: "socks5://127.0.0.1:1080"
|
|
|
|
http_proxy: "socks5://127.0.0.1:1080"
|
|
|
|
https_proxy: "socks5://127.0.0.1:1080"
|
|
|
|
run: |
|
|
|
|
echo "Checking if ALL_PROXY is set (proxy expected):"
|
|
|
|
if [ -z "$ALL_PROXY" ]; then
|
|
|
|
echo "No ALL_PROXY set. Not using proxy."
|
|
|
|
else
|
|
|
|
echo "ALL_PROXY is set to $ALL_PROXY. Proxy in use."
|
|
|
|
fi
|
|
|
|
echo "Attempting to access example.com with proxy..."
|
|
|
|
curl -s --max-time 10 https://example.com || echo "Request failed, even with proxy."
|