-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55e282d
commit 6833c2b
Showing
6 changed files
with
141 additions
and
27 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Detect new version | ||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
workflow_dispatch: | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
issues: write | ||
env: | ||
IMAGE_NAME: ib-gateway-docker | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
- name: detect new ib gateway version | ||
id: check-update | ||
run: | | ||
ib-gateway-ver=$(python scripts/detect_ib_gateway_ver.py) >> "$GITHUB_OUTPUT" | ||
python scripts/detect_ibc_ver.py | ||
ibc-ver=${IBC_VER} >> "$GITHUB_OUTPUT" | ||
ibc-asset-url=${IBC_ASSET_URL} >> "$GITHUB_OUTPUT" | ||
cur-ib-gateway-ver=$(cat ib-gateway-ver) | ||
cur-ibc-ver=$(cat ibc-ver) | ||
if [ "$ib-gateway-ver" = "$cur-ib-gateway-ver" ]; then | ||
echo "No dated IB gateway version" | ||
has_update=false >> "$GITHUB_OUTPUT" | ||
else | ||
echo "New IB gateway version($ib-gateway-ver)" | ||
has_update=true >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: Update files with new version | ||
if: steps.check-update.outputs.has_update == 'true' | ||
run: | | ||
cat README.template | envsubst > README.md | ||
cat Dockerfile.template | envsubst > Dockerfile | ||
- name: Create PR | ||
if: ${{ steps.check-update.outputs.has_update == 'true' }} | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
branch='feat/update-to-${{ steps.check-update.outputs.ib-gateway-ver }}' | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git pull | ||
git checkout -b "$branch" origin/master | ||
git add * | ||
git commit -m 'Update to `${{ steps.check-update.outputs.ib-gateway-ver }}`' | ||
git push --set-upstream origin "$branch" | ||
# gh pr create --base master --fill | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
FROM python:3.11-slim | ||
# IBC Version : https://github.com/IbcAlpha/IBC/releases | ||
ARG IBC_VER="3.18.0" | ||
ARG IBC_ASSET_URL="https://github.com/IbcAlpha/IBC/releases/download/$IBC_VER-Update.1/IBCLinux-$IBC_VER.zip" | ||
|
||
# install dependencies | ||
RUN apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get install -y wget \ | ||
unzip \ | ||
xvfb \ | ||
libxtst6 \ | ||
libxrender1 \ | ||
build-essential \ | ||
net-tools \ | ||
x11-utils \ | ||
socat \ | ||
expect \ | ||
procps \ | ||
xterm | ||
RUN apt install -y openjdk-17-jre | ||
|
||
# set environment variables | ||
ENV TWS_INSTALL_LOG=/root/Jts/tws_install.log \ | ||
IBC_INI=/root/ibc/config.ini \ | ||
IBC_PATH=/opt/ibc \ | ||
javaPath=/opt/i4j_jres \ | ||
TWS_PATH=/root/Jts \ | ||
twsSettingsPath=/root/Jts \ | ||
TWOFA_TIMEOUT_ACTION=restart | ||
|
||
# make dirs | ||
RUN mkdir -p /tmp && mkdir -p ${IBC_PATH} && mkdir -p ${TWS_PATH} | ||
|
||
# download IB TWS | ||
RUN wget -q -O /tmp/ibgw.sh https://download2.interactivebrokers.com/installers/ibgateway/stable-standalone/ibgateway-stable-standalone-linux-x64.sh | ||
RUN chmod +x /tmp/ibgw.sh | ||
|
||
# download IBC | ||
RUN wget -q -O /tmp/IBC.zip ${IBC_ASSET_URL} | ||
RUN unzip /tmp/IBC.zip -d ${IBC_PATH} | ||
RUN chmod +x ${IBC_PATH}/*.sh ${IBC_PATH}/*/*.sh | ||
|
||
# install TWS, write output to file so that we can parse the TWS version number later | ||
RUN touch $TWS_INSTALL_LOG | ||
COPY install_ibgw.exp /tmp/install_ibgw.exp | ||
RUN chmod +x /tmp/install_ibgw.exp | ||
RUN /tmp/install_ibgw.exp | ||
|
||
# remove downloaded files | ||
RUN rm /tmp/ibgw.sh /tmp/IBC.zip | ||
|
||
# copy IBC/Jts configs | ||
COPY ibc/config.ini ${IBC_INI} | ||
|
||
# copy cmd script | ||
WORKDIR /root | ||
COPY cmd.sh /root/cmd.sh | ||
RUN chmod +x /root/cmd.sh | ||
|
||
# set display environment variable (must be set after TWS installation) | ||
ENV DISPLAY=:0 | ||
|
||
ENV IBGW_PORT 4002 | ||
|
||
EXPOSE $IBGW_PORT | ||
|
||
ENTRYPOINT [ "sh", "/root/cmd.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.18.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import requests | ||
import os | ||
|
||
if __name__ == "__main__": | ||
url = "https://api.github.com/repos/IbcAlpha/IBC/releases" | ||
response = requests.get(url) | ||
data = response.json() | ||
latest = data[0] | ||
ver = latest["name"] | ||
for asset in latest["assets"]: | ||
if asset["name"].startswith("IBCLinux"): | ||
asset_url = asset["browser_download_url"] | ||
os.putenv("IBC_VER", ver) | ||
os.putenv("IBC_ASSET_URL", asset_url) | ||
print(ver) | ||
print(asset_url) |