Compare commits
No commits in common. "dd7a238eb8f1cca52666a777118b7d12584e7cc4" and "06a99271f1daeb1ac5896bba7f021a211a41aa55" have entirely different histories.
dd7a238eb8
...
06a99271f1
@ -8,8 +8,7 @@ steps:
|
|||||||
image: node:18.16.0-bullseye
|
image: node:18.16.0-bullseye
|
||||||
commands:
|
commands:
|
||||||
# - git config --global --add safe.directory "/drone/src"
|
# - git config --global --add safe.directory "/drone/src"
|
||||||
- corepack enable
|
- npm install -g pnpm
|
||||||
- corepack prepare pnpm@latest --activate
|
|
||||||
- pnpm i --frozen-lockfile
|
- pnpm i --frozen-lockfile
|
||||||
- pnpm build
|
- pnpm build
|
||||||
environment:
|
environment:
|
||||||
|
@ -6,8 +6,11 @@ SCRIPTS_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
|||||||
__netlify_upload() {
|
__netlify_upload() {
|
||||||
local branch="$BRANCH_NAME"
|
local branch="$BRANCH_NAME"
|
||||||
local production="$DEPLOY_PRODUCTION"
|
local production="$DEPLOY_PRODUCTION"
|
||||||
[[ "$BRANCH_NAME" = "main" ]] && production="true"
|
|
||||||
[[ -z "$production" ]] && production="false"
|
[[ -z "$production" ]] && production="false"
|
||||||
|
if [[ "$BRANCH_NAME" = "main" ]]; then
|
||||||
|
production="true"
|
||||||
|
branch=""
|
||||||
|
fi
|
||||||
|
|
||||||
curl -sL \
|
curl -sL \
|
||||||
-H "Content-Type: application/zip" \
|
-H "Content-Type: application/zip" \
|
||||||
@ -23,23 +26,6 @@ __netlify_get_deploy() {
|
|||||||
"https://api.netlify.com/api/v1/deploys/${deploy_id}"
|
"https://api.netlify.com/api/v1/deploys/${deploy_id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Publish a deployment to main URL.
|
|
||||||
__netlify_promote() {
|
|
||||||
local deploy_id="$1"
|
|
||||||
curl -sL \
|
|
||||||
-H "Authorization: Bearer ${NETLIFY_API_KEY}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
--data "{}" \
|
|
||||||
"https://api.netlify.com/api/v1/sites/${NETLIFY_SITE_ID}/deploys/${deploy_id}/restore"
|
|
||||||
}
|
|
||||||
|
|
||||||
__netlify_get_error() {
|
|
||||||
local error_message
|
|
||||||
error_message="$(json_get "$upload_resp" message)"
|
|
||||||
[[ "$error_message" = "null" ]] && error_message="$(json_get "$upload_resp" error_message)"
|
|
||||||
echo -n "$error_message"
|
|
||||||
}
|
|
||||||
|
|
||||||
json_get() {
|
json_get() {
|
||||||
local json_body="$1"
|
local json_body="$1"
|
||||||
shift
|
shift
|
||||||
@ -51,7 +37,9 @@ deploy_netlify() {
|
|||||||
local upload_resp
|
local upload_resp
|
||||||
upload_resp="$(__netlify_upload "$1")"
|
upload_resp="$(__netlify_upload "$1")"
|
||||||
|
|
||||||
local error_message="$(__netlify_get_error "$upload_resp")"
|
local error_message
|
||||||
|
error_message="$(json_get "$upload_resp" message)"
|
||||||
|
[[ "$error_message" = "null" ]] && error_message="$(json_get "$upload_resp" error_message)"
|
||||||
|
|
||||||
if [[ "$error_message" != "null" ]]; then
|
if [[ "$error_message" != "null" ]]; then
|
||||||
echo "Deploy to netlify failed:"
|
echo "Deploy to netlify failed:"
|
||||||
@ -72,7 +60,7 @@ deploy_netlify() {
|
|||||||
echo " * main url: $(json_get "$deploy_resp" 'ssl_url')"
|
echo " * main url: $(json_get "$deploy_resp" 'ssl_url')"
|
||||||
echo " * branch: $(json_get "$deploy_resp" 'deploy_ssl_url')"
|
echo " * branch: $(json_get "$deploy_resp" 'deploy_ssl_url')"
|
||||||
echo " * permalink: $(json_get "$deploy_resp" 'links' 'permalink')"
|
echo " * permalink: $(json_get "$deploy_resp" 'links' 'permalink')"
|
||||||
break
|
return 0
|
||||||
;;
|
;;
|
||||||
error)
|
error)
|
||||||
echo "Deploy to netlify failed:"
|
echo "Deploy to netlify failed:"
|
||||||
@ -85,26 +73,10 @@ deploy_netlify() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ "$BRANCH_NAME" = "main" ]]; then
|
|
||||||
echo "Promoting latest main build..."
|
|
||||||
local promote_resp="$(__netlify_promote "$(json_get "$deploy_resp" 'id')")"
|
|
||||||
error_message="$(__netlify_get_error "$promote_resp")"
|
|
||||||
|
|
||||||
if [[ "$error_message" != "null" ]]; then
|
|
||||||
echo "Promote netlify deploy failed:"
|
|
||||||
echo " * ${error_message}"
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
echo 'Deoployed to main url.'
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# For deployment, we care a bit less
|
# For deployment, we care a bit less
|
||||||
if [[ -n "${NETLIFY_API_KEY}" && -n "${NETLIFY_SITE_ID}" ]]; then
|
if [[ -n "${NETLIFY_API_KEY}" && -n "${NETLIFY_SITE_ID}" ]]; then
|
||||||
echo "Deploy to netlify..."
|
echo "Deploy to netlify..."
|
||||||
deploy_netlify um-react.zip
|
deploy_netlify um-react.zip
|
||||||
else
|
|
||||||
echo "skip netlify deployment."
|
|
||||||
fi
|
fi
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env node
|
#!/bin/env node
|
||||||
/* eslint-env node */
|
/* eslint-env node */
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
Loading…
Reference in New Issue
Block a user