Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/prod-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# deploys a new instance of rain solver
name: Deploy A New Rain Solver Worker

on:
workflow_dispatch:
inputs:
deployment:
description: "Choose From Available Deployments"
required: true
type: choice
options:
- flare

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- run: |
deployment=${{ inputs.deployment }}
echo "rpc=PROD_${deployment^^}_RPC" >> $GITHUB_ENV

- name: Checkout Repo
id: checkout
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.PUBLISHER_SSH_KEY }}
submodules: recursive
fetch-depth: 0

- name: Install Nix 1/2
uses: DeterminateSystems/nix-installer-action@main
with:
determinate: true
- name: Install Nix 2/2
uses: DeterminateSystems/flakehub-cache-action@main

- name: Deploy New ${{ inputs.deployment }} Worker
env:
HYPERDX_API_KEY: ${{ secrets.HYPERDX_API_KEY }}
PROD_WALLET_KEY: ${{ secrets.PROD_WALLET_KEY }}
RPC_URL: ${{ secrets[env.rpc] }}
run: |
# Use envsubst to replace secrets in spec.yaml
nix develop -c envsubst -i deployments/${{ inputs.deployment }}/specs.yaml -o spec.yaml

# Deploy
nix develop -c doctl apps create -t ${{ secrets.DOCTL_API_KEY }} --project-id ${{ secrets.DOCTL_PROJECT_ID }} --spec spec.yaml -o json > result.json
echo "APP_ID=$(jq -r '.[0].id' result.json)" >> $GITHUB_ENV
echo "${{ env.APP_ID }}" > deployments/${{ inputs.deployment }}/id.txt

# rm temp files
rm -f result.json spec.yaml

- name: Commit Changes
run: |
git add "deployments/${{ inputs.deployment }}/id.txt"
git commit -m "New Deployment ${{ inputs.deployment }} [skip ci]"

- name: Push Changes To Remote
run: git push origin
34 changes: 34 additions & 0 deletions .github/workflows/prod-rebuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Forces a rebuild of rain solver worker source
name: Rebuild A Rain Solver Worker

on:
workflow_dispatch:
inputs:
deployment:
description: "Choose From Available Deployments"
required: true
type: choice
options:
- flare

jobs:
rebuild:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
id: checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Install Nix 1/2
uses: DeterminateSystems/nix-installer-action@main
with:
determinate: true
- name: Install Nix 2/2
uses: DeterminateSystems/flakehub-cache-action@main

- name: Rebuild ${{ inputs.deployment }} Worker
run: nix develop -c doctl apps create-deployment $(cat deployments/${{ inputs.deployment }}/id.txt) -t ${{ secrets.DOCTL_API_KEY }} --force-rebuild

34 changes: 34 additions & 0 deletions .github/workflows/prod-restart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# soft restart the rain solver worker
name: Restart A Rain Solver Worker

on:
workflow_dispatch:
inputs:
deployment:
description: "Choose From Available Deployments"
required: true
type: choice
options:
- flare

jobs:
restart:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
id: checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Install Nix 1/2
uses: DeterminateSystems/nix-installer-action@main
with:
determinate: true
- name: Install Nix 2/2
uses: DeterminateSystems/flakehub-cache-action@main

- name: Restart ${{ inputs.deployment }} Worker
run: nix develop -c doctl apps restart $(cat deployments/${{ inputs.deployment }}/id.txt) -t ${{ secrets.DOCTL_API_KEY }}

48 changes: 48 additions & 0 deletions .github/workflows/prod-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# updates the rain solver configuration only, i.e. without updating the source
name: Update A Rain Solver Worker Configurations

on:
workflow_dispatch:
inputs:
deployment:
description: "Choose From Available Deployments"
required: true
type: choice
options:
- flare

jobs:
update:
runs-on: ubuntu-latest
steps:
- run: |
deployment=${{ inputs.deployment }}
echo "rpc=PROD_${deployment^^}_RPC" >> $GITHUB_ENV

- name: Checkout Repo
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Install Nix 1/2
uses: DeterminateSystems/nix-installer-action@main
with:
determinate: true
- name: Install Nix 2/2
uses: DeterminateSystems/flakehub-cache-action@main

- name: Update ${{ inputs.deployment }} Worker
env:
HYPERDX_API_KEY: ${{ secrets.HYPERDX_API_KEY }}
PROD_WALLET_KEY: ${{ secrets.PROD_WALLET_KEY }}
RPC_URL: ${{ secrets[env.rpc] }}
run: |
# Use envsubst to replace secrets in spec.yaml
nix develop -c envsubst -i deployments/${{ inputs.deployment }}/specs.yaml -o spec.yaml

# Deploy
nix develop -c doctl apps update $(cat deployments/${{ inputs.deployment }}/id.txt) -t ${{ secrets.DOCTL_API_KEY }} --spec spec.yaml

# rm temp files
rm -f spec.yaml
47 changes: 47 additions & 0 deletions .github/workflows/prod-upgrade.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# updates all rain solver workers to latest upstream changes
name: Upgrade Rain Solver Workers With Latest Production Changes

on:
push:
branches:
- main

jobs:
upgrade:
runs-on: ubuntu-latest
strategy:
matrix:
deployment: [flare]
fail-fast: false
steps:
- run: |
deployment=${{ matrix.deployment }}
echo "rpc=PROD_${deployment^^}_RPC" >> $GITHUB_ENV

- name: Checkout Repo
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Install Nix 1/2
uses: DeterminateSystems/nix-installer-action@main
with:
determinate: true
- name: Install Nix 2/2
uses: DeterminateSystems/flakehub-cache-action@main

- name: Upgrade ${{ matrix.deployment }} Worker
env:
HYPERDX_API_KEY: ${{ secrets.HYPERDX_API_KEY }}
PROD_WALLET_KEY: ${{ secrets.PROD_WALLET_KEY }}
RPC_URL: ${{ secrets[env.rpc] }}
run: |
# Use envsubst to replace secrets in spec.yaml
nix develop -c envsubst -i deployments/${{ matrix.deployment }}/specs.yaml -o spec.yaml

# Upgrade to latest upstream source
nix develop -c doctl apps update $(cat deployments/${{ matrix.deployment }}/id.txt) -t ${{ secrets.DOCTL_API_KEY }} --spec spec.yaml --update-sources

# rm temp files
rm -f spec.yaml
16 changes: 16 additions & 0 deletions deployments/flare/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
key: $BOT_WALLET_PRIVATEKEY
rpc: $RPC_URL
subgraph:
- https://api.goldsky.com/api/public/project_clv14x04y9kzi01saerx7bxpg/subgraphs/ob4-flare/2024-12-13-9dc7/gn
arbAddress: "0x5376Ffa8fbE804f3D9292bc6b319b0e59Ce42311"
dispair: "0xE3989Ea7486c0F418C764e6c511e86f6E8830FAb"
sleep: 10
poolUpdateInterval: 60
txGas: 110%
botMinBalance: 1
gasPriceMultiplier: 115
maxRatio: true
rpOnly: true
sgFilter:
includeOwners:
- "0x7177b9d00bB5dbcaaF069CC63190902763783b09"
44 changes: 44 additions & 0 deletions deployments/flare/specs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
alerts:
- rule: DEPLOYMENT_FAILED
- rule: DOMAIN_FAILED

features:
- buildpack-stack=ubuntu-22

ingress: {}
name: flare-bot-test-poc
region: nyc

workers:
- image:
registry: rainprotocol
registry_type: DOCKER_HUB
repository: arb-bot
tag: master
instance_count: 1
instance_size_slug: apps-s-1vcpu-0.5gb
name: flare-bot-test-poc

envs:
- key: BOT_WALLET_PRIVATEKEY
scope: RUN_AND_BUILD_TIME
type: SECRET
value: $PROD_WALLET_KEY

- key: RPC_URL
scope: RUN_AND_BUILD_TIME
type: SECRET
value: $RPC_URL

- key: HYPERDX_API_KEY
scope: RUN_AND_BUILD_TIME
type: SECRET
value: $HYPERDX_API_KEY

- key: TRACER_SERVICE_NAME
scope: RUN_AND_BUILD_TIME
value: flare-bot-test-poc

- key: CONFIG
scope: RUN_AND_BUILD_TIME
value: deployments/flare/config.yaml
Loading