-
Notifications
You must be signed in to change notification settings - Fork 2
134 lines (126 loc) · 5.46 KB
/
update_schedule.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
131
132
133
134
---
name: "Update daily - Horoscope"
#on: push
on:
schedule:
- cron: "20 1 * * *"
env:
FILE_WEBSITE: website.html
LIST_SIGNES: BELIER TAUREAU GEMEAUX CANCER LION VIERGE BALANCE SCORPION SAGITTAIRE CAPRICORNE VERSEAU POISSONS
jobs:
build_jour:
env:
URL: http://www.astroo.com/horoscope.php
FILE: docs/jour.json
FILE_TMP: docs/jour_tmp.json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Website
run: curl -s $URL -o $FILE_WEBSITE
- name: Create JSON
run: |
echo "{" > $FILE_TMP
echo " \"date\": \"$(date +%F)\"," >> $FILE_TMP
for SIGNE in $LIST_SIGNES; do echo " \"${SIGNE,,}\": \"$(cat $FILE_WEBSITE |grep "$SIGNE</a>" |awk -F'</span>' '{ print $2 }' |sed 's/"/\\"/g' |sed 's/\ *$//g')\"," >> $FILE_TMP ; done
sed -i '$ s/.$//' $FILE_TMP
echo "}" >> $FILE_TMP
- name: Recode UTF8
run: |
sudo apt-get update
sudo apt-get -y install recode
cat $FILE_TMP | recode html..utf8 > $FILE
- name: Commit JSON
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add $FILE
git commit -m "Generated $FILE" || true
git pull --rebase
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
build_hebdomadaire:
env:
FILE: docs/hebdomadaire.json
FILE_TMP: docs/hebdomadaire_tmp.json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Website
run: |
for SIGNE in $LIST_SIGNES; do curl -s http://www.astroo.com/horoscopes/horoscope_hebdo_${SIGNE,,}.php -o ${SIGNE}.html; done
- name: Extract data
run: |
for SIGNE in $LIST_SIGNES; do cat ${SIGNE}.html |awk -v RS="</*td>" '/class="hhte" valign="top"/{if (++n == 1) print $0}' |sed 's/<td class="hhte" valign="top">//g' |sed 's/<br>//g' |tr -d '\n' > ${SIGNE}_CADRAN_1 ; done
for SIGNE in $LIST_SIGNES; do cat ${SIGNE}.html |awk -v RS="</*td>" '/class="hhte" valign="top"/{if (++n == 2) print $0}' |sed 's/<td class="hhte" valign="top">//g' |sed 's/<br>//g' |tr -d '\n' > ${SIGNE}_CADRAN_2 ; done
for SIGNE in $LIST_SIGNES; do cat ${SIGNE}.html |awk -v RS="</*td>" '/class="hhte" valign="top"/{if (++n == 3) print $0}' |sed 's/<td class="hhte" valign="top">//g' |sed 's/<br>//g' |tr -d '\n' > ${SIGNE}_CADRAN_3 ; done
sed -i 's/^\ *//g' *CADRAN*
sed -i 's/\"/\\"/g' *CADRAN*
- name: Create JSON
run: |
echo "{" > $FILE_TMP
echo " \"date\": \"$(date +%F)\"," >> $FILE_TMP
for SIGNE in $LIST_SIGNES; do echo " \"${SIGNE,,}\": [\"\", \"$(cat ${SIGNE}_CADRAN_1)\", \"$(cat ${SIGNE}_CADRAN_2)\", \"$(cat ${SIGNE}_CADRAN_3)\" ]," >> $FILE_TMP ; done
sed -i '$ s/.$//' $FILE_TMP
echo "}" >> $FILE_TMP
- name: recode UTF8
run: |
sudo apt-get update
sudo apt-get -y install recode
cat $FILE_TMP | recode html..utf8 > $FILE
- name: Commit JSON
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add $FILE
git commit -m "Generated $FILE" || true
git pull --rebase
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
build_mensuel:
env:
FILE: docs/mensuel.json
FILE_TMP: docs/mensuel_tmp.json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Website
run: |
for SIGNE in $LIST_SIGNES; do curl -s http://www.astroo.com/horoscopes/horoscope_du_mois_${SIGNE,,}.php -o ${SIGNE}.html; done
- name: Extract data
run: |
for SIGNE in $LIST_SIGNES; do cat ${SIGNE}.html |awk -v RS="</*td>" '/class="hhte" valign="top"/{if (++n == 1) print $0}' |sed 's/<td class="hhte" valign="top">//g' |sed 's/<br>//g' |tr -d '\n' > ${SIGNE}_CADRAN_1 ; done
for SIGNE in $LIST_SIGNES; do cat ${SIGNE}.html |awk -v RS="</*td>" '/class="hhte" valign="top"/{if (++n == 2) print $0}' |sed 's/<td class="hhte" valign="top">//g' |sed 's/<br>//g' |tr -d '\n' > ${SIGNE}_CADRAN_2 ; done
for SIGNE in $LIST_SIGNES; do cat ${SIGNE}.html |awk -v RS="</*td>" '/class="hhte" valign="top"/{if (++n == 3) print $0}' |sed 's/<td class="hhte" valign="top">//g' |sed 's/<br>//g' |tr -d '\n' > ${SIGNE}_CADRAN_3 ; done
sed -i 's/^\ *//g' *CADRAN*
sed -i 's/\"/\\"/g' *CADRAN*
- name: Create JSON
run: |
echo "{" > $FILE_TMP
echo " \"date\": \"$(date +%F)\"," >> $FILE_TMP
for SIGNE in $LIST_SIGNES; do echo " \"${SIGNE,,}\": [\"$(cat ${SIGNE}_CADRAN_1)\", \"$(cat ${SIGNE}_CADRAN_2)\", \"$(cat ${SIGNE}_CADRAN_3)\" ]," >> $FILE_TMP ; done
sed -i '$ s/.$//' $FILE_TMP
echo "}" >> $FILE_TMP
- name: recode UTF8
run: |
sudo apt-get update
sudo apt-get -y install recode
cat $FILE_TMP | recode html..utf8 > $FILE
- name: Commit JSON
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add $FILE
git commit -m "Generated $FILE" || true
git pull --rebase
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true