2019-10-11 19:22:20 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
2019-10-07 22:19:11 +02:00
|
|
|
|
2019-10-11 20:01:57 +02:00
|
|
|
export HOME="/github/workspace"
|
|
|
|
export NVM_DIR="/github/workspace/nvm"
|
|
|
|
export WRANGLER_HOME="/github/workspace"
|
|
|
|
|
2019-10-11 21:25:47 +02:00
|
|
|
# h/t https://github.com/elgohr/Publish-Docker-Github-Action
|
2019-10-11 21:37:26 +02:00
|
|
|
sanitize() {
|
|
|
|
if [ -z "${1}" ]
|
|
|
|
then
|
2019-10-11 21:41:24 +02:00
|
|
|
>&2 echo "Unable to find ${2}. Did you set secrets.${2}?"
|
2019-10-11 21:25:47 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-10-11 21:30:51 +02:00
|
|
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
|
|
|
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
|
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
|
|
|
|
|
|
|
mkdir -p "$HOME/.wrangler"
|
2019-10-15 17:52:07 +02:00
|
|
|
chmod -R 770 "$HOME/.wrangler"
|
2019-10-11 21:30:51 +02:00
|
|
|
|
2019-10-14 22:30:15 +02:00
|
|
|
sanitize "${INPUT_EMAIL}" "email"
|
|
|
|
sanitize "${INPUT_APIKEY}" "apiKey"
|
2019-10-14 22:04:41 +02:00
|
|
|
|
2019-10-14 22:27:43 +02:00
|
|
|
export CF_EMAIL="$INPUT_EMAIL"
|
|
|
|
export CF_API_KEY="$INPUT_APIKEY"
|
2019-10-11 21:30:51 +02:00
|
|
|
|
|
|
|
npm i @cloudflare/wrangler -g
|
2019-10-14 22:24:54 +02:00
|
|
|
|
|
|
|
if [ -z "$INPUT_ENVIRONMENT" ]
|
|
|
|
then
|
|
|
|
wrangler publish
|
2019-10-14 22:33:15 +02:00
|
|
|
else
|
|
|
|
wrangler publish -e "$INPUT_ENVIRONMENT"
|
2019-10-14 22:24:54 +02:00
|
|
|
fi
|
2019-10-11 21:30:51 +02:00
|
|
|
|