1
0
mirror of synced 2025-12-21 02:46:50 -05:00
Files
docs/script/purge-fastly
Kevin Heis 11d8e415da Check repository references (#16680)
* Check repository references

* Remove "foundRepoNames" that I used to find all the unique names

* A little speed up with Set

* Ignore a few files

* Remove remaining references

* Update README.md
2020-12-03 16:41:03 +00:00

35 lines
1011 B
Bash
Executable File

#!/usr/bin/env bash
# [start-readme]
#
# Run this script to manually purge the Fastly cache.
# Note this script requires a `FASTLY_SERVICE_ID` and `FASTLY_TOKEN` in your `.env` file.
#
# [end-readme]
usage()
{
echo "Error! Unable to purge the Fastly cache"
echo ""
echo "Add FASTLY_SERVICE_ID and FASTLY_TOKEN to the environment or create a .env file in the project root and set these values:"
echo ""
echo "FASTLY_SERVICE_ID=<value-goes-here>"
echo "FASTLY_TOKEN=<value-goes-here>"
exit
}
# attempt to load from .env if Fastly config is not already in ENV
if [ -z "$FASTLY_SERVICE_ID" ] || [ -z "$FASTLY_TOKEN" ]; then
# abort if .env file doesn't exist
[ -f .env ] || usage
# load config from .env
export $(cat .env | xargs)
fi
if [ -z "$FASTLY_SERVICE_ID" ] || [ -z "$FASTLY_TOKEN" ]; then
usage
else
curl -H "fastly-key: $FASTLY_TOKEN" -H "accept: application/json" -H "fastly-soft-purge: 1" -X POST "https://api.fastly.com/service/$FASTLY_SERVICE_ID/purge/all-the-things"
fi