Use gitea actions for updates (#1)
All checks were successful
Push commit / report (push) Successful in 4s
All checks were successful
Push commit / report (push) Successful in 4s
Reviewed-on: a31/CEC-list-monitoring#1
This commit is contained in:
parent
718d42183f
commit
9f7c6d9fed
14
.gitea/workflows/update-list.yaml
Normal file
14
.gitea/workflows/update-list.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
name: Push commit
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
schedule:
|
||||||
|
- cron: "*/30 * * * *"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
report:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: https://github.com/ischanx/checkout@06c611454073903c9d44641d7e085b21115d3dcf
|
||||||
|
|
||||||
|
- run: bash update_cec_list.bash
|
27
stdin2discord.bash
Normal file
27
stdin2discord.bash
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
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"
|
@ -1,25 +0,0 @@
|
|||||||
import sys
|
|
||||||
import requests
|
|
||||||
|
|
||||||
def send(_msg: str):
|
|
||||||
if len(_msg) == 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
r = requests.post(
|
|
||||||
url='https://discord.com/api/webhooks/936927833572380692/QrqoK8aVCOkGFh1L0HaHPd_Z-Usj-ubhXYvHadZyCA1Y5GOB7-0xWmuyKI9l4byvKjQ1',
|
|
||||||
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)
|
|
@ -1,27 +1,19 @@
|
|||||||
#!/usr/bin/bash
|
#!/usr/bin/bash
|
||||||
|
|
||||||
cd ~/CEC_monitoring || { exit 1; echo "changing directory failed"; exit 1; }
|
|
||||||
|
|
||||||
http_response=$(curl -s -L -o list.csv -w "%{http_code}" "https://docs.google.com/spreadsheets/d/e/2PACX-1vTXE8HCavThmJt1Wshy3GyF2ZJ-264SbNRVucsPUe2rbEgpm-e3tqsX-8K2mwsG4ozBj6qUyOOd4RMe/pub?gid=1832580214&single=true&output=csv")
|
http_response=$(curl -s -L -o list.csv -w "%{http_code}" "https://docs.google.com/spreadsheets/d/e/2PACX-1vTXE8HCavThmJt1Wshy3GyF2ZJ-264SbNRVucsPUe2rbEgpm-e3tqsX-8K2mwsG4ozBj6qUyOOd4RMe/pub?gid=1832580214&single=true&output=csv")
|
||||||
if [ $http_response != "200" ]; then
|
if [ $http_response != "200" ]; then
|
||||||
#echo "page not found"
|
#echo "page not found"
|
||||||
#cat list.csv
|
#cat list.csv
|
||||||
git reset --hard | grep -v "HEAD is now at"
|
git reset --hard
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
else
|
else
|
||||||
|
git config user.name 'user2'
|
||||||
|
git config user.email 'user2@localhost'
|
||||||
|
git remote set-url origin https://x-access-token:$GITHUB_TOKEN@gitea.demb.uk/$GITHUB_REPOSITORY
|
||||||
git diff "list.csv"
|
git diff "list.csv"
|
||||||
git diff "list.csv" | python3 stdin2discord.py
|
git diff "list.csv" | bash stdin2discord.bash
|
||||||
git add "list.csv"
|
git add "list.csv"
|
||||||
git commit -m "commit" 2>/dev/null >/dev/null
|
git commit -m "commit"
|
||||||
git push 2>/dev/null
|
git push
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#curl -L -o "list.csv" -s "https://docs.google.com/spreadsheets/d/e/2PACX-1vTXE8HCavThmJt1Wshy3GyF2ZJ-264SbNRVucsPUe2rbEgpm-e3tqsX-8K2mwsG4ozBj6qUyOOd4RMe/pub?gid=1832580214&single=true&output=csv" || { echo "downloading failed"; exit 1; }
|
|
||||||
|
|
||||||
#git diff "list.csv"
|
|
||||||
#git add "list.csv"
|
|
||||||
#git commit -m "commit" | grep -vE 'On branch master|nothing to commit, working tree clean'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user