Skip to content

Detect new version #212

Detect new version

Detect new version #212

name: Detect new version
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
env:
IMAGE_NAME: ib-gateway-docker
IBC_VERSION_JSON_URL: "https://api.github.com/repos/IbcAlpha/IBC/releases"
steps:
- uses: actions/checkout@master
- name: detect new ib gateway version
id: check-update
run: |
IB_GATEWAY_VER=$(curl "https://download2.interactivebrokers.com/installers/ibgateway/stable-standalone/version.json" | \
grep -Eo '[^ibgatewaystable_callback(](.+})' | jq -r '.buildVersion')
IBC_VER=$(curl ${IBC_VERSION_JSON_URL} | jq -r '.[0].name')
source .env
HAS_UPDATE='false'
if [ "$IB_GATEWAY_VER" = "$CUR_IB_GATEWAY_VER" ]; then
echo "No new IB gateway version available"
echo has_update=false >> "$GITHUB_OUTPUT"
else
echo "New IB gateway version($IB_GATEWAY_VER)"
echo has_update=true >> "$GITHUB_OUTPUT"
HAS_UPDATE='true'
fi
if [ "$HAS_UPDATE" = 'false' ]; then
if [ "$IBC_VER" = "$CUR_IBC_VER" ]; then
echo "No new IBC version available"
echo has_update=false >> "$GITHUB_OUTPUT"
else
echo "New IBC version($IBC_VER) available"
echo has_update=true >> "$GITHUB_OUTPUT"
fi
fi
echo "ib-gateway-ver=$IB_GATEWAY_VER" >> "$GITHUB_OUTPUT"
echo "ibc-ver=$IBC_VER" >> "$GITHUB_OUTPUT"
- name: Update files with new version
if: steps.check-update.outputs.has_update == 'true'
run: |
sed -e 's/###IB_GATEWAY_VER###/${{steps.check-update.outputs.ib-gateway-ver}}/' -e 's/###IBC_VER###/${{steps.check-update.outputs.ibc-ver}}/' README.template > README.md
- 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 }}-ibc${{steps.check-update.outputs.ibc-ver}}'
git config user.name github-actions
git config user.email [email protected]
git config advice.addIgnoredFile false
git stash push README.md
git pull
git checkout -b "$branch" origin/develop
# Update files
git stash pop stash@{0}
echo "CUR_IB_GATEWAY_VER=${{ steps.check-update.outputs.ib-gateway-ver }}" > .env
echo "CUR_IBC_VER=${{ steps.check-update.outputs.ibc-ver }}" >> .env
#####
git add README.md
git add -f .env
git commit -m 'Update to `${{ steps.check-update.outputs.ib-gateway-ver }}`'
git push --set-upstream origin "$branch"
gh pr create --base develop --fill