Introduce using of gitea actions for updates #1

Merged
norohind merged 20 commits from actions-test into master 2023-09-09 19:06:48 +03:00
2 changed files with 26 additions and 26 deletions
Showing only changes of commit 3a14049973 - Show all commits

26
stdin2discord.bash Normal file
View File

@ -0,0 +1,26 @@
#!/bin/bash
send() {
local _msg=$1
if [[ -z $_msg ]]; then
return
fi
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"content\":\"$_msg\"}" \
"$DISCORD_WEBHOOK"
}
msg=""
while IFS= read -r line; do
if [[ ${#msg}${#line} -ge 2000 ]]; then
send "$msg"
msg=""
else
msg+="$line"
fi
done
send "$msg"

View File

@ -1,26 +0,0 @@
import sys
import requests
import os
def send(_msg: str):
if len(_msg) == 0:
return
r = requests.post(
url=os.environ['DISCORD_WEBHOOK'],
data=f'content=```diff\n{requests.utils.quote(_msg)}```'.encode('utf-8'),
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
)
r.raise_for_status()
msg = ''
for line in sys.stdin:
if len(msg + line) >= 2000:
send(msg)
msg = ''
else:
msg += line
send(msg)