mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2024-11-24 10:54:46 +01:00
Switch to inputs
This commit is contained in:
parent
271f26dd01
commit
c3eb4af3f6
2 changed files with 35 additions and 17 deletions
|
@ -3,3 +3,10 @@ description: 'Cloudflare Workers Deploy'
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: 'Dockerfile'
|
image: 'Dockerfile'
|
||||||
|
inputs:
|
||||||
|
apiKey:
|
||||||
|
description: "Your Cloudflare API Key"
|
||||||
|
required: true
|
||||||
|
email:
|
||||||
|
description: "Your Cloudflare Email"
|
||||||
|
required: true
|
||||||
|
|
|
@ -6,25 +6,36 @@ export HOME="/github/workspace"
|
||||||
export NVM_DIR="/github/workspace/nvm"
|
export NVM_DIR="/github/workspace/nvm"
|
||||||
export WRANGLER_HOME="/github/workspace"
|
export WRANGLER_HOME="/github/workspace"
|
||||||
|
|
||||||
|
function install_nvm() {
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
mkdir -p "$HOME/.wrangler"
|
mkdir -p "$HOME/.wrangler"
|
||||||
chmod -R 777 "$HOME/.wrangler"
|
chmod -R 777 "$HOME/.wrangler"
|
||||||
|
|
||||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
|
install_nvm
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
|
||||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
|
||||||
|
|
||||||
if [ -n "$CLOUDFLARE_API_KEY" ]; then
|
sanitize "${INPUT_EMAIL}" "email"
|
||||||
echo "CLOUDFLARE_API_KEY env var needs to be set. Add this field in the 'Secrets' section of your repo's settings."
|
export CLOUDFLARE_EMAIL="$INPUT_EMAIL"
|
||||||
exit 1
|
sanitize "${INPUT_APIKEY}" "apiKey"
|
||||||
fi
|
export CLOUDFLARE_API_KEY="$INPUT_APIKEY"
|
||||||
|
|
||||||
if [ -n "$CLOUDFLARE_EMAIL" ]; then
|
|
||||||
echo "CLOUDFLARE_EMAIL env var needs to be set. Add this field in the 'Secrets' section of your repo's settings."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
npm i @cloudflare/wrangler -g
|
npm i @cloudflare/wrangler -g
|
||||||
npm i
|
npm i
|
||||||
|
|
||||||
wrangler whoami
|
wrangler whoami
|
||||||
wrangler publish
|
wrangler publish
|
||||||
|
}
|
||||||
|
|
||||||
|
# h/t https://github.com/elgohr/Publish-Docker-Github-Action
|
||||||
|
function sanitize() {
|
||||||
|
if [ -z "${1}" ]; then
|
||||||
|
>&2 echo "Unable to find the ${2}. Did you set with.${2}?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
||||||
|
|
Loading…
Reference in a new issue