1
0
Fork 0
mirror of https://gitlab.com/futo-org/fcast.git synced 2025-08-19 22:02:49 +00:00

Added automatic deploy with cache purge.

This commit is contained in:
Koen 2023-06-28 10:15:01 +02:00
parent 615ff3bef5
commit e7476d916d
2 changed files with 30 additions and 1 deletions

View file

@ -1,5 +1,7 @@
deployWebsite: deployWebsite:
stage: deployWebsite stage: deployWebsite
before_script:
- cd website
script: script:
- wrangler pages deploy website --project-name=fcast --branch=main - sh deploy.sh
when: manual when: manual

27
website/deploy.sh Normal file
View file

@ -0,0 +1,27 @@
#!/bin/sh
DOCUMENT_ROOT=/var/www/fcast
# Take site offline
echo "Taking site offline..."
touch $DOCUMENT_ROOT/maintenance.file
# Swap over the content
echo "Deploying content..."
cp index.html $DOCUMENT_ROOT/
cp privacy-policy.html $DOCUMENT_ROOT/
cp favicon.png $DOCUMENT_ROOT/
cp -r css $DOCUMENT_ROOT/
cp -r images $DOCUMENT_ROOT/
cp -r js $DOCUMENT_ROOT/
cp -r vendor $DOCUMENT_ROOT/
# Notify Cloudflare to wipe the CDN cache
echo "Purging Cloudflare cache..."
curl -X POST "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/purge_cache" \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'
# Take site back online
echo "Bringing site back online..."
rm $DOCUMENT_ROOT/maintenance.file