ci: avoid installing debian dependencies
This commit is contained in:
parent
ce0117c389
commit
f10459ab69
@ -27,9 +27,6 @@ steps:
|
|||||||
from_secret: NETLIFY_API_KEY
|
from_secret: NETLIFY_API_KEY
|
||||||
commands:
|
commands:
|
||||||
# - git config --global --add safe.directory "/drone/src"
|
# - git config --global --add safe.directory "/drone/src"
|
||||||
# 让 Debian 使用中科大源;测试网易和阿里的源速度不理想。
|
- python3 -m zipfile -c etc.zip um-react.zip dist/.
|
||||||
- sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
|
|
||||||
- apt-get update && apt-get install -y zip jq tar gzip curl
|
|
||||||
- (cd dist && zip -r -9 ../um-react.zip .)
|
|
||||||
- ./scripts/publish.sh
|
- ./scripts/publish.sh
|
||||||
- ./scripts/deploy.sh
|
- ./scripts/deploy.sh
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
BRANCH_NAME="$(git branch --show-current)"
|
BRANCH_NAME="$(git branch --show-current)"
|
||||||
|
SCRIPTS_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
__netlify_upload() {
|
__netlify_upload() {
|
||||||
local branch="$BRANCH_NAME"
|
local branch="$BRANCH_NAME"
|
||||||
@ -25,35 +26,45 @@ __netlify_get_deploy() {
|
|||||||
"https://api.netlify.com/api/v1/deploys/${deploy_id}"
|
"https://api.netlify.com/api/v1/deploys/${deploy_id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
json_get() {
|
||||||
|
local json_body="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
echo -n "$json_body" | "${SCRIPTS_DIR}/read_json.mjs" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
deploy_netlify() {
|
deploy_netlify() {
|
||||||
local upload_resp
|
local upload_resp
|
||||||
upload_resp="$(__netlify_upload "$1")"
|
upload_resp="$(__netlify_upload "$1")"
|
||||||
|
|
||||||
local error_message="$(echo "$upload_resp" | jq -r ".message // .error_message")"
|
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:"
|
||||||
echo " * ${error_message}"
|
echo " * ${error_message}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local deploy_id="$(echo "$upload_resp" | jq -r ".id")"
|
local deploy_id="$(json_get "$upload_resp" id)"
|
||||||
local deploy_resp=""
|
local deploy_resp=""
|
||||||
local deploy_state=""
|
local deploy_state=""
|
||||||
local retry_count=10
|
local retry_count=10
|
||||||
while [[ "$retry_count" -gt 0 ]]; do
|
while [[ "$retry_count" -gt 0 ]]; do
|
||||||
deploy_resp="$(__netlify_get_deploy "$deploy_id")"
|
deploy_resp="$(__netlify_get_deploy "$deploy_id")"
|
||||||
deploy_state="$(echo "$deploy_resp" | jq -r '.state')"
|
deploy_state="$(json_get "$deploy_resp" 'state')"
|
||||||
case "$deploy_state" in
|
case "$deploy_state" in
|
||||||
ready)
|
ready)
|
||||||
echo 'Deploy to netlify OK!'
|
echo 'Deploy to netlify OK!'
|
||||||
echo " * main url: $(echo "$deploy_resp" | jq -r '.ssl_url')"
|
echo " * main url: $(json_get "$deploy_resp" 'ssl_url')"
|
||||||
echo " * branch: $(echo "$deploy_resp" | jq -r '.deploy_ssl_url')"
|
echo " * branch: $(json_get "$deploy_resp" 'deploy_ssl_url')"
|
||||||
echo " * permalink: $(echo "$deploy_resp" | jq -r '.links.permalink')"
|
echo " * permalink: $(json_get "$deploy_resp" 'links' 'permalink')"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
error)
|
error)
|
||||||
echo "Deploy to netlify failed:"
|
echo "Deploy to netlify failed:"
|
||||||
echo " * $(echo "$deploy_resp" | jq -r '.error_message')"
|
echo " * $(json_get "$deploy_resp" 'error_message')"
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
12
scripts/read_json.mjs
Executable file
12
scripts/read_json.mjs
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/env node
|
||||||
|
/* eslint-env node */
|
||||||
|
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
const data = JSON.parse(fs.readFileSync(0, 'utf-8').trim());
|
||||||
|
|
||||||
|
let value = data;
|
||||||
|
for (let i = 2; i < process.argv.length; i++) {
|
||||||
|
value = value[process.argv[i]] ?? null;
|
||||||
|
}
|
||||||
|
process.stdout.write(String(value), 'utf-8');
|
Loading…
Reference in New Issue
Block a user