dn42-info/deploy.py
Minecon724 056e040433
Some checks failed
/ deploy (push) Failing after 26s
so much bloat (nodejs) for a GIT CLONE lmaooo???
2024-05-12 17:59:40 +02:00

35 lines
No EOL
972 B
Python

from ftplib import FTP
import requests
import minify_html
from os import listdir, getenv
from io import BytesIO
# init ftp
print(getenv('FTP_SERVER'))
ftp = FTP(getenv('FTP_SERVER'))
ftp.login(getenv('FTP_USER'), getenv('FTP_PASSWORD'))
for f in [i for i in listdir('html') if i.endswith('.html')]:
# 1. Minify the index.html file using minify-html
minified_content = minify_html.minify(open(f, 'r').read(), minify_css=True, minify_css_level_3=True, do_not_minify_doctype=True)
# 2. Upload the file to an FTP server
ftp.storbinary('STOR ' + f, BytesIO(minified_content.encode()))
ftp.storbinary('STOR geofeed.csv', BytesIO(open('../geofeed.csv', 'r').read().encode()))
# refresh cache
url = 'https://api.bunny.net/purge?url=https%3A%2F%2Fdn42.724.rocks&async=false' # replace with your URL
headers = {
'AccessKey': getenv("ACCESS_KEY")
}
response = requests.get(url, headers=headers)
# Quit ftp
ftp.quit()