110 lines (101 loc) · 2.79 KB
/
deploy-to-ibm.yml
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
name: Deploy to IBM Cloud
on:
push:
branches:
- master
schedule:
- cron: "12 21 * * 4"
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: init
run: |
wget -q https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-linux-64.zip
unzip -o v2ray-linux-64.zip "v2ray" "v2ctl" "geosite.dat" "geoip.dat"
rm -rf v2ray-linux-64.zip
chmod 700 v2ray v2ctl
touch `date +%Y%m%d%H%M%S`
cat > config.json << EOF
{
"inbounds": [
{
"port": 8080,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "${{ secrets.CF_UUID_IBM }}",
"alterId": 64
}
]
},
"streamSettings": {
"network":"ws",
"wsSettings": {
"path": "${{ secrets.CF_WSPATH_IBM }}"
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}
EOF
cat > manifest.yml << EOF
---
applications:
- name: v2fly
memory: 128M
disk_quota: 128M
routes:
- route: ${{ secrets.CF_ROUTE_IBM }}
command: ./v2ray
buildpacks:
- binary_buildpack
EOF
mkdir workers
cat > ./workers/index.js << EOF
addEventListener(
"fetch", event => {
let url = new URL(event.request.url);
url.host = "${{ secrets.CF_ROUTE_IBM }}";
let request = new Request(url, event.request);
event.respondWith(
fetch(request)
)
}
)
EOF
cat > ./workers/wrangler.toml <<EOF
name= "${{ secrets.CF_WORKER_NAME_CF }}"
account_id = "${{ secrets.CF_ACCOUNT_ID_CF }}"
type= "javascript"
workers_dev = true
EOF
cat > ./workers/package.json << EOF
{
"name": "workers-fly",
"main": "index.js"
}
EOF
- name: cloudfoundry
uses: citizen-of-planet-earth/cf-cli-action@v1
with:
cf_api: https://api.us-south.cf.cloud.ibm.com
cf_username: ${{ secrets.CF_USER_IBM }}
cf_password: ${{ secrets.CF_PASSWORD_IBM }}
cf_org: ${{ secrets.CF_ORG_IBM }}
cf_space: ${{ secrets.CF_SPACE_IBM }}
command: push
- name: workers
uses: cloudflare/wrangler-action@1.2.0
with:
apiKey: ${{ secrets.CF_API_KEY_CF }}
email: ${{ secrets.CF_EMAIL_CF }}
workingDirectory: 'workers'