-
Notifications
You must be signed in to change notification settings - Fork 39
148 lines (133 loc) · 5.99 KB
/
createWebNews.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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Post Web News
on:
workflow_dispatch:
inputs:
select_web:
type: choice
description: Post News on Beta or Official Website?
options:
- Beta
- Official
default: "Beta"
schedule:
# Schedule for posting to Beta Website at 10:00 AM
- cron: "30 9 * * 1-5"
# Schedule for posting to Official Website at 11:00 AM
- cron: "0 10 * * 1-5"
jobs:
prepare_news:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Cache Python packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install pytz
pip install py7zr
pip install aiohttp
pip install chardet
pip install aiofiles
pip install requests
pip install elasticsearch==7.13.4
sudo apt-get install p7zip-full
- name: Build News File
env:
ES_HOST: ${{ secrets.ES_HOST }}
ES_USER: ${{ secrets.ES_USER }}
ES_PASSWORD: ${{ secrets.ES_PASSWORD }}
MIKROE_NECTO_AWS: ${{ secrets.MIKROE_NECTO_AWS }}
RELEASES_SPREADSHEET: ${{ secrets.RELEASES_SPREADSHEET }}
run: |
python -u scripts/build_message_web.py "NECTO DAILY UPDATE" "$RELEASES_SPREADSHEET" ${{ secrets.ES_INDEX_LIVE }} ${{ secrets.ES_CLICKS_INDEX_LIVE }}
- name: Notify Post Message Failure
if: failure()
env:
MATTERMOST_WEBHOOK_URL_SDK: ${{ secrets.MATTERMOST_WEBHOOK_URL_SDK }}
run: |
MESSAGE="**Check Release Spreadsheet or update the Calendar - there is no SDK Packages for today's Necto Daily Update Web News.**"
curl -X POST -H 'Content-Type: application/json' \
--data "{\"text\": \"$MESSAGE\"}" \
$MATTERMOST_WEBHOOK_URL_SDK
- name: Upload News File
uses: actions/upload-artifact@v3
with:
name: news-file
path: message.txt
post_beta:
needs: prepare_news
if: >
((github.event_name == 'schedule' && github.event.schedule == '30 9 * * 1-5') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.select_web == 'Beta'))
runs-on: ubuntu-latest
steps:
- name: Download News File
uses: actions/download-artifact@v3
with:
name: news-file
- name: Post message on Beta Website
env:
MIKROE_BETA_URL: ${{ secrets.MIKROE_BETA_URL }}
run: |
MESSAGE=$(cat message.txt)
curl --user ${{ secrets.WEB_BETA_USER }}:${{ secrets.WEB_BETA_PASSWORD }} "$MIKROE_BETA_URL" \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: PHPSESSID=bdu5qnabbu4bpucutoqa4dea95; PrestaShop-c70d81b27989da2e05775a7416c2a451=7LlCRwFwicyVSo9CGkRIGxvgnGHSZknmUUGAf4FagfDu1ZAio%2B%2Fm0fGU6AWzPnSalLDnm99ipnraikuHQ6qumZwMervfogxNSuEvoN%2BXqM8o6osXcG%2FwXztgwd1U4C4LVMKjv9sDymWMFO%2FOKCvzsu5tK28MUdAF%2FP77lxnnZDNOLTj8MniASlaesF%2FyxiE6RqmLq%2FVc9H4oCwQWccZH2XvbTHOeBYynAx6x%2B%2BJJDf7ODMWvOuyjrkmLvbNPZ5sO000185' \
--data-urlencode "title=Release for $(date +"%a %b %d")" \
--data-urlencode 'description=Beta release' \
--data-urlencode 'category=SW daily release' \
--data-urlencode "date=$(date +"%Y-%m-%d %H:%M:%S")" \
--data-urlencode "body=$MESSAGE"
- name: Notify Mattermost - Web News Ready
env:
MATTERMOST_WEBHOOK_URL_SDK: ${{ secrets.MATTERMOST_WEBHOOK_URL_SDK }}
run: |
CURRENT_DATE=$(date +'%Y-%m-%d')
MESSAGE="**Beta Web News posted for $CURRENT_DATE.**\n> Take a look at [Beta Website](https://beta.mikroe.com/)\n"
curl -X POST -H 'Content-Type: application/json' \
--data "{\"text\": \"$MESSAGE\"}" \
$MATTERMOST_WEBHOOK_URL_SDK
post_official:
needs: prepare_news
if: >
((github.event_name == 'schedule' && github.event.schedule == '0 10 * * 1-5') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.select_web == 'Official'))
runs-on: ubuntu-latest
steps:
- name: Download News File
uses: actions/download-artifact@v3
with:
name: news-file
- name: Post message on Official Website
env:
MIKROE_OFFICIAL_URL: ${{ secrets.MIKROE_OFFICIAL_URL }}
run: |
MESSAGE=$(cat message.txt)
curl --location $MIKROE_OFFICIAL_URL \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: PHPSESSID=bdu5qnabbu4bpucutoqa4dea95; PrestaShop-c70d81b27989da2e05775a7416c2a451=7LlCRwFwicyVSo9CGkRIGxvgnGHSZknmUUGAf4FagfDu1ZAio%2B%2Fm0fGU6AWzPnSalLDnm99ipnraikuHQ6qumZwMervfogxNSuEvoN%2BXqM8o6osXcG%2FwXztgwd1U4C4LVMKjv9sDymWMFO%2FOKCvzsu5tK28MUdAF%2FP77lxnnZDNOLTj8MniASlaesF%2FyxiE6RqmLq%2FVc9H4oCwQWccZH2XvbTHOeBYynAx6x%2B%2BJJDf7ODMWvOuyjrkmLvbNPZ5sO000185' \
--data-urlencode "title=Release for $(date +"%a %b %d")" \
--data-urlencode 'description=Official release' \
--data-urlencode 'category=SW daily release' \
--data-urlencode "date=$(date +"%Y-%m-%d %H:%M:%S")" \
--data-urlencode "body=$MESSAGE"
- name: Notify Mattermost - Web News Ready
env:
MATTERMOST_WEBHOOK_URL_SDK: ${{ secrets.MATTERMOST_WEBHOOK_URL_SDK }}
run: |
CURRENT_DATE=$(date +'%Y-%m-%d')
MESSAGE="**Official Web News posted for $CURRENT_DATE.**\n> Take a look at [MIKROE Website](https://www.mikroe.com/)\n"
curl -X POST -H 'Content-Type: application/json' \
--data "{\"text\": \"$MESSAGE\"}" \
$MATTERMOST_WEBHOOK_URL_SDK