diff --git a/website/.gitlab-ci.yml b/website/.gitlab-ci.yml index 5226eb8..3267760 100644 --- a/website/.gitlab-ci.yml +++ b/website/.gitlab-ci.yml @@ -1,5 +1,7 @@ deployWebsite: stage: deployWebsite + before_script: + - cd website script: - - wrangler pages deploy website --project-name=fcast --branch=main + - sh deploy.sh when: manual \ No newline at end of file diff --git a/website/deploy.sh b/website/deploy.sh new file mode 100644 index 0000000..7495d08 --- /dev/null +++ b/website/deploy.sh @@ -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 \ No newline at end of file