-
Notifications
You must be signed in to change notification settings - Fork 2.6k
130 lines (129 loc) · 4.47 KB
/
main.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: 'update schedule'
on:
schedule:
- cron: '0 22 * * *'
- cron: '0 10 * * *'
workflow_dispatch:
branches:
- master
- dev
- gd
- gd-test
jobs:
push:
runs-on: ${{ matrix.operating-system }}
timeout-minutes: 120
strategy:
matrix:
operating-system: ['ubuntu-20.04']
steps:
- name: Set branch name
id: vars
run: echo "BRANCH_NAME=${{ github.repository_owner == 'Guovin' && 'gd' || 'master' }}" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
ref: ${{ env.BRANCH_NAME }}
- name: Run with setup-python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8'
update-environment: true
cache: 'pipenv'
- name: Check open_driver config
id: check_driver
run: |
echo "OPEN_DRIVER=$(python -c '
try:
from utils.config import config
open_driver = config.getboolean("Settings", "open_driver")
except:
open_driver = False
print(open_driver)')" >> $GITHUB_ENV
- name: Check open_ffmpeg config
id: check_ffmpeg
run: |
echo "OPEN_FFMPEG=$(python -c '
try:
from utils.config import config
open_ffmpeg = config.getboolean("Settings", "open_ffmpeg")
except:
open_ffmpeg = False
print(open_ffmpeg)')" >> $GITHUB_ENV
- name: Install Selenium
if: env.OPEN_DRIVER == 'True' || env.OPEN_DRIVER == 'true'
run: |
sudo pip3 install selenium
- name: Set up Chrome
if: env.OPEN_DRIVER == 'True' || env.OPEN_DRIVER == 'true'
uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable
- name: Download chrome driver
if: env.OPEN_DRIVER == 'True' || env.OPEN_DRIVER == 'true'
uses: nanasess/setup-chromedriver@master
- name: Launch chrome driver
if: env.OPEN_DRIVER == 'True' || env.OPEN_DRIVER == 'true'
run: |
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
- name: Install FFmpeg
if: env.OPEN_FFMPEG == 'True' || env.OPEN_FFMPEG == 'true'
run: sudo apt-get update && sudo apt-get install -y ffmpeg
- name: Install pipenv
run: pip3 install --user pipenv
- name: Install dependecies
run: pipenv --python 3.8 && pipenv install
- name: Build
run: pipenv run build
- name: Commit and push if changed
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git diff
final_file=$(python -c '
try:
from utils.config import config
final_file = config.get("Settings", "final_file")
except:
final_file = "output/result.txt"
print(final_file)')
final_m3u_file=$(python -c '
try:
from utils.config import config
import os
final_file = config.get("Settings", "final_file")
final_m3u_file = os.path.splitext(final_file)[0] + ".m3u"
except:
final_m3u_file = "output/result.m3u"
print(final_m3u_file)')
if [[ -f "$final_file" ]]; then
git add -f "$final_file"
fi
if [[ -f "result.txt" ]]; then
git add -f "result.txt"
fi
if [[ -f "$final_m3u_file" ]]; then
git add -f "$final_m3u_file"
fi
if [[ -f "result.m3u" ]]; then
git add -f "result.m3u"
fi
if [[ -f "output/result_cache.pkl" ]]; then
git add -f "output/result_cache.pkl"
fi
if [[ -f "output/user_result.log" ]]; then
git add -f "output/user_result.log"
elif [[ -f "output/result.log" ]]; then
git add -f "output/result.log"
fi
if [[ -f "updates/fofa/fofa_hotel_region_result.pkl" ]]; then
git add -f "updates/fofa/fofa_hotel_region_result.pkl"
fi
if [[ -f "updates/fofa/fofa_multicast_region_result.pkl" ]]; then
git add -f "updates/fofa/fofa_multicast_region_result.pkl"
fi
if ! git diff --staged --quiet; then
git commit -m "Github Action Auto Updated"
git push --force
fi