Skip to content

Commit

Permalink
update workflows
Browse files Browse the repository at this point in the history
align image-files with latest
  • Loading branch information
gnzsnz committed Nov 26, 2023
1 parent 547053d commit b49acb9
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 18 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/detect-ibc-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ on:

workflow_dispatch:

defaults:
run:
shell: "bash -Eeuo pipefail -x {0}"

env:
IBC_REPO: https://github.com/IbcAlpha/IBC.git
BRANCH_PREFIX: IBC-update
jobs:
detect-release:
name: Detect Release
runs-on: ubuntu-latest
outputs:
update: ${{ steps.verify_latest.outputs.update }}
strategy:
fail-fast: true

Expand Down Expand Up @@ -86,3 +93,15 @@ jobs:
git push --set-upstream origin "$branch"
gh pr create --base master --fill
build:
name: Call build workflow
needs: detect-release
if: needs.detect-release.outputs.update == 'true'
strategy:
matrix:
channel: ['stable', 'latest']
uses: gnzsnz/ib-gateway-docker/.github/workflows/build.yml@master
with:
channel: ${{ matrix.channel }}
12 changes: 12 additions & 0 deletions .github/workflows/detect-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ defaults:
jobs:
detect-release:
runs-on: ubuntu-latest
outputs:
update: ${{ steps.check-update.outputs.has_update }}
channel: ${{ matrix.channel }}
strategy:
fail-fast: true
matrix:
Expand Down Expand Up @@ -112,3 +115,12 @@ jobs:
git push --set-upstream origin "$t_branch"
gh pr create --base master --fill
build:
name: Call build workflow
needs: detect-release
if: needs.detect-release.outputs.update == 'true'
uses: gnzsnz/ib-gateway-docker/.github/workflows/build.yml@master
with:
channel: ${{ needs.detect-release.outputs.channel }}
20 changes: 10 additions & 10 deletions .github/workflows/on-push-n-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ name: Docker Image CI

on:
push:
branches: ['*', '!update-*-to-*']
branches: ['*', '!update-*-to-*', '!IBC-update*']
pull_request:
branches: [ 'master', '!update-*-to-*' ]
branches: ['master', '!update-*-to-*', '!IBC-update*']

jobs:
build:
name: Build image
strategy:
matrix:
channel: ['stable', 'latest']
uses: gnzsnz/ib-gateway-docker/.github/workflows/build.yml@master
with:
channel: ${{ matrix.channel }}
build:
name: Build image
strategy:
matrix:
channel: ['stable', 'latest']
uses: gnzsnz/ib-gateway-docker/.github/workflows/build.yml@master
with:
channel: ${{ matrix.channel }}
3 changes: 2 additions & 1 deletion Dockerfile.tws.template
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ ARG DEBIAN_FRONTEND=noninteractive

RUN \
apt-get update -y && \
apt-get install --no-install-recommends --yes socat sshpass gettext-base && \
apt-get install --no-install-recommends --yes socat sshpass gettext-base \
libnspr4 libnss3 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* # end

Expand Down
11 changes: 9 additions & 2 deletions image-files/scripts/common.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# shellcheck disable=SC1091

setup_ssh() {
# setup SSH Tunnel
Expand All @@ -16,13 +17,19 @@ setup_ssh() {
echo ".> SSH options: $SSH_ALL_OPTIONS"

if [ -n "$SSH_PASSPHRASE" ]; then
if [ -z "${SSH_AUTH_SOCK}" ]; then
if ! pgrep ssh-agent >/dev/null; then
# start agent if it's not already running
# https://wiki.archlinux.org/title/SSH_keys#SSH_agents
echo ".> Starting ssh-agent."
eval "$(ssh-agent -s)"
ssh-agent >"/config/.ssh-agent.env"
source "/config/.ssh-agent.env"
echo ".> ssh-agent sock: ${SSH_AUTH_SOCK}"
else
echo ".> ssh-agent already running"
if [ -z "${SSH_AUTH_SOCK}" ]; then
echo ".> Loading agent environment"
source "/config/.ssh-agent.env"
fi
echo ".> ssh-agent sock: ${SSH_AUTH_SOCK}"
fi

Expand Down
8 changes: 7 additions & 1 deletion image-files/scripts/port_forwarding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ fi

if [ "$SSH_TUNNEL" = "yes" ]; then

if [ -n "$(pgrep -x ssh)" ]; then
# if this script is already running don't start it
echo ".> SSH tunnel already active. Not starting a new one"
exit 0
fi

if [ -z "$SSH_REMOTE_PORT" ]; then
# by default remote port is same than API_PORT
SSH_REMOTE_PORT="$API_PORT"
Expand All @@ -29,7 +35,7 @@ if [ "$SSH_TUNNEL" = "yes" ]; then
fi

while true; do
echo ".> ssh sock: $SSH_AUTH_SOCK"
echo ".> Starting ssh tunnel with ssh sock: $SSH_AUTH_SOCK"
bash -c "ssh ${SSH_ALL_OPTIONS} -TNR 127.0.0.1:${API_PORT}:localhost:${SSH_REMOTE_PORT} ${SSH_SCREEN:-} ${SSH_USER_TUNNEL}"
sleep "${SSH_RESTART:-5}"
done
Expand Down
7 changes: 3 additions & 4 deletions image-files/tws-scripts/run_tws.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
# shellcheck shell=bash
# shellcheck disable=SC1091,SC2317

echo "*************************************************************************"
echo ".> Starting IBC/TWS"
echo "*************************************************************************"
# shellcheck disable=SC1091
# source common functions
source "${SCRIPT_PATH}/common.sh"

Expand All @@ -20,6 +20,8 @@ disable_agents() {
pkill -x ssh-agent
pkill -x gpg-agent
touch /config/.config/disable_agents
else
echo ".> Found '/config/.config/disable_agents' agents already disabled"
fi
}

Expand All @@ -42,9 +44,6 @@ apply_settings
# forward ports, socat or ssh
"${SCRIPT_PATH}/port_forwarding.sh" &

# settings
apply_settings

# start IBC
echo ".> Starting IBC with params:"
echo ".> Version: ${TWS_MAJOR_VRSN}"
Expand Down
5 changes: 5 additions & 0 deletions image-files/tws-scripts/start_session.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ echo ".> Setting user password"
echo "abc:$_PASS" | chpasswd
id

if [ -n "${TZ}" ]; then
echo ".> Setting timezone to: ${TZ}"
echo "${TZ}" >/etc/timezone
fi

# open xfce session
echo ".> Openning Xrdp session"
echo "${_PASS}" | xrdp-sesrun -s 127.0.0.1 -F 0 abc
Expand Down

0 comments on commit b49acb9

Please sign in to comment.