From 06eda50a168e0fe74773569752550786250d9fb9 Mon Sep 17 00:00:00 2001 From: Stavros Panakakis Date: Wed, 13 Apr 2022 21:27:33 +0300 Subject: [PATCH] universe: netlify: replace curl-based wrapper with cli Signed-off-by: Stavros Panakakis --- pkg/universe.dagger.io/netlify/deploy.sh | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/pkg/universe.dagger.io/netlify/deploy.sh b/pkg/universe.dagger.io/netlify/deploy.sh index 164a3074..396c5902 100755 --- a/pkg/universe.dagger.io/netlify/deploy.sh +++ b/pkg/universe.dagger.io/netlify/deploy.sh @@ -6,12 +6,7 @@ NETLIFY_AUTH_TOKEN="$(cat /run/secrets/token)" export NETLIFY_AUTH_TOKEN create_site() { - url="https://api.netlify.com/api/v1/${NETLIFY_ACCOUNT:-}/sites" - - curl -s -S --fail-with-body -H "Authorization: Bearer $NETLIFY_AUTH_TOKEN" \ - -X POST -H "Content-Type: application/json" \ - "$url" \ - -d "{\"name\": \"${NETLIFY_SITE_NAME}\", \"custom_domain\": \"${NETLIFY_DOMAIN}\"}" -o body + netlify api createSite -d "{ \"body\": {\"name\": \"${NETLIFY_SITE_NAME}\", \"custom_domain\": \"${NETLIFY_DOMAIN}\"} }" > body # shellcheck disable=SC2181 if [ $? -ne 0 ]; then @@ -23,11 +18,7 @@ create_site() { jq -r '.site_id' body } -site_id=$( - curl -s -S -f -H "Authorization: Bearer $NETLIFY_AUTH_TOKEN" \ - "https://api.netlify.com/api/v1/sites?filter=all" | - jq -r ".[] | select(.name==\"$NETLIFY_SITE_NAME\") | .id" -) +site_id=$(netlify api listSites | jq -r ".[] | select(.name==\"${NETLIFY_SITE_NAME}\") | .id") if [ -z "$site_id" ]; then if [ "${NETLIFY_SITE_CREATE:-}" != 1 ]; then echo "Site $NETLIFY_SITE_NAME does not exist"