fix: bind Olons support to production IM
Deploy olons-server production / deploy (push) Successful in 52s
Deploy olons-server production / deploy (push) Successful in 52s
This commit is contained in:
+23
-15
@@ -49,10 +49,8 @@ jobs:
|
||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
|
||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||
OLONS_IM_INTERNAL_SECRET: ${{ secrets.OLONS_IM_INTERNAL_SECRET }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
test -n "$OLONS_IM_INTERNAL_SECRET"
|
||||
install -d -m 700 "$HOME/.ssh"
|
||||
KEY_FILE="$(mktemp "$HOME/.ssh/olns-deploy.XXXXXX")"
|
||||
cleanup() {
|
||||
@@ -66,19 +64,6 @@ jobs:
|
||||
SSH_ARGS=(-i "$KEY_FILE" -o BatchMode=yes -o StrictHostKeyChecking=yes)
|
||||
printf '%s' "$REGISTRY_TOKEN" | ssh "${SSH_ARGS[@]}" "$DEPLOY_USER@$DEPLOY_HOST" \
|
||||
"docker login git.olns.shop -u admin --password-stdin"
|
||||
printf '%s' "$OLONS_IM_INTERNAL_SECRET" | ssh "${SSH_ARGS[@]}" "$DEPLOY_USER@$DEPLOY_HOST" '
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
secret="$(cat)"
|
||||
test -n "$secret"
|
||||
printf "OLONS_IM_INTERNAL_SECRET=%s\n" "$secret" > /opt/olns/.env.olons-server
|
||||
cat > /opt/olns/compose.olons-server-secret.yaml <<"YAML"
|
||||
services:
|
||||
olons-server:
|
||||
env_file:
|
||||
- .env.olons-server
|
||||
YAML
|
||||
'
|
||||
ssh "${SSH_ARGS[@]}" "$DEPLOY_USER@$DEPLOY_HOST" '
|
||||
set -euo pipefail
|
||||
cd /opt/olns
|
||||
@@ -90,6 +75,29 @@ jobs:
|
||||
fi
|
||||
done
|
||||
test -n "$base_file"
|
||||
|
||||
im_container="$(docker compose -f "$base_file" ps -q im-server)"
|
||||
test -n "$im_container"
|
||||
internal_secret="$(docker inspect "$im_container" --format '"'"'{{range .Config.Env}}{{println .}}{{end}}'"'"' | sed -n '"'"'s/^INTERNAL_API_HOTGO_SECRET=//p'"'"' | head -n 1)"
|
||||
test -n "$internal_secret"
|
||||
|
||||
umask 077
|
||||
{
|
||||
printf "OLONS_IM_INTERNAL_SECRET=%s\n" "$internal_secret"
|
||||
printf "OLONS_IM_BASE_URL=https://im-api.yuexuan.shop\n"
|
||||
printf "OLONS_IM_HTTP_API_URL=https://im-api.yuexuan.shop/v1/im\n"
|
||||
printf "OLONS_IM_WS_URL=wss://im-api.yuexuan.shop/v0/channels\n"
|
||||
printf "OLONS_IM_FILE_URL=https://im-api.yuexuan.shop/v0/file\n"
|
||||
printf "OLONS_IM_TENANT_CODE=default\n"
|
||||
printf "OLONS_IM_INTERNAL_SERVICE=olons-server\n"
|
||||
} > .env.olons-server
|
||||
cat > compose.olons-server-secret.yaml <<"YAML"
|
||||
services:
|
||||
olons-server:
|
||||
env_file:
|
||||
- .env.olons-server
|
||||
YAML
|
||||
|
||||
docker compose -f "$base_file" -f compose.olons-server-secret.yaml pull olons-server
|
||||
docker compose -f "$base_file" -f compose.olons-server-secret.yaml up -d --no-deps --wait olons-server
|
||||
docker compose -f "$base_file" -f compose.olons-server-secret.yaml exec -T olons-server sh -c '"'"'test -n "$OLONS_IM_INTERNAL_SECRET"'"'"'
|
||||
|
||||
Reference in New Issue
Block a user