Skip to content

Commit 75ce8fa

Browse files
Adhoc/deploy to railway (#2)
* add gsm and gluex integrations * update env vars * Prep for railway deployment * deploy liquidator contracts * add hyperevm chain config * Add cloud formation scripts * Add github actions --------- Co-authored-by: alphak3y <alphak3y@protonmail.com>
1 parent 8c50e94 commit 75ce8fa

36 files changed

+2560
-73
lines changed

.dockerignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
**/.classpath
1111
**/.dockerignore
1212
**/.env
13-
**/.git
1413
**/.gitignore
1514
**/.project
1615
**/.settings
@@ -31,5 +30,4 @@
3130
**/secrets.dev.yaml
3231
**/values.dev.yaml
3332
LICENSE
34-
README.md
35-
**/lib
33+
README.md

.env.example

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ MAINNET_RPC_URL=https://example.rpc.url.com
77
BASE_RPC_URL=https://example.base_rpc.url.com
88
ARBITRUM_RPC_URL=https://example.arbitrum_rpc.url.com
99

10-
# Swap API URL
11-
SWAP_API_URL=https://example.api.url.com
10+
# GlueX API Configuration
11+
GLUEX_API_KEY=your_gluex_api_key_here
12+
GLUEX_API_URL=https://router.gluex.xyz/v1/quote
13+
GLUEX_UNIQUE_PID=your_unique_partner_id_here
1214

1315
### OPTIONAL ###
1416

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Deploy CDK Stack
2+
description: Deploys individual CDK Stacks defined in `cdk/app.py` using Python CDK
3+
4+
inputs:
5+
account:
6+
description: The AWS account id to deploy to
7+
required: false
8+
default: "730335381248"
9+
region:
10+
description: The AWS region to deploy to
11+
required: false
12+
default: "ap-northeast-1"
13+
stacks:
14+
description: The stacks to deploy, separated by ' '
15+
required: true
16+
working-directory:
17+
required: false
18+
description: An optional working directory where the CDK code is located
19+
default: ./
20+
deploy-parameters:
21+
required: false
22+
description: Optional additional parameters for 'cdk-deploy'
23+
default: ""
24+
python-version:
25+
description: The Python version to use
26+
required: false
27+
default: "3.13"
28+
29+
runs:
30+
using: composite
31+
steps:
32+
- name: Set up Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: ${{ inputs.python-version }}
36+
37+
- name: Install CDK CLI
38+
shell: bash
39+
run: npm install -g aws-cdk
40+
41+
- name: Install Python dependencies
42+
shell: bash
43+
working-directory: ${{ inputs.working-directory }}/cdk
44+
run: |
45+
python -m pip install --upgrade pip
46+
pip install -r requirements.txt
47+
48+
- name: Configure AWS credentials
49+
uses: aws-actions/configure-aws-credentials@master
50+
with:
51+
role-to-assume: arn:aws:iam::${{ inputs.account }}:role/github-actions
52+
aws-region: ${{ inputs.region }}
53+
54+
- name: Deploy | cdk
55+
shell: bash
56+
working-directory: ${{ inputs.working-directory }}
57+
env:
58+
CDK_DEPLOY_ACCOUNT: ${{ inputs.account }}
59+
CDK_DEPLOY_REGION: ${{ inputs.region }}
60+
run: cdk synth --exclusively ${{ inputs.stacks }} --require-approval never ${{ inputs.deploy-parameters }}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Deploy CDK Stack
2+
description: Deploys individual CDK Stacks defined in `cdk/app.py` using Python CDK
3+
4+
inputs:
5+
account:
6+
description: The AWS account id to deploy to
7+
required: false
8+
default: "730335381248"
9+
region:
10+
description: The AWS region to deploy to
11+
required: false
12+
default: "ap-northeast-1"
13+
stacks:
14+
description: The stacks to deploy, separated by ' '
15+
required: true
16+
working-directory:
17+
required: false
18+
description: An optional working directory where the CDK code is located
19+
default: ./
20+
deploy-parameters:
21+
required: false
22+
description: Optional additional parameters for 'cdk-deploy'
23+
default: ""
24+
python-version:
25+
description: The Python version to use
26+
required: false
27+
default: "3.13"
28+
29+
runs:
30+
using: composite
31+
steps:
32+
- name: Set up Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: ${{ inputs.python-version }}
36+
37+
- name: Install CDK CLI
38+
shell: bash
39+
run: npm install -g aws-cdk
40+
41+
- name: Install Python dependencies
42+
shell: bash
43+
working-directory: ${{ inputs.working-directory }}/cdk
44+
run: |
45+
python -m pip install --upgrade pip
46+
pip install -r requirements.txt
47+
48+
- name: Configure AWS credentials
49+
uses: aws-actions/configure-aws-credentials@master
50+
with:
51+
role-to-assume: arn:aws:iam::${{ inputs.account }}:role/github-actions
52+
aws-region: ${{ inputs.region }}
53+
54+
- name: Deploy | cdk
55+
shell: bash
56+
working-directory: ${{ inputs.working-directory }}
57+
env:
58+
CDK_DEPLOY_ACCOUNT: ${{ inputs.account }}
59+
CDK_DEPLOY_REGION: ${{ inputs.region }}
60+
run: cdk deploy --exclusively ${{ inputs.stacks }} --require-approval never ${{ inputs.deploy-parameters }}

.github/workflows/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# GitHub Actions Workflows
2+
3+
## Deploy Workflow
4+
5+
The `deploy.yml` workflow automatically deploys the liquidation bot to AWS ECS using CDK when code is pushed to the `main` branch.
6+
7+
### Required GitHub Secrets
8+
9+
Configure the following secrets in your GitHub repository settings (Settings → Secrets and variables → Actions):
10+
11+
**Required:**
12+
1. **AWS_ACCESS_KEY_ID** - AWS access key with permissions to deploy CDK stacks
13+
2. **AWS_SECRET_ACCESS_KEY** - AWS secret access key
14+
3. **AWS_ACCOUNT_ID** - AWS account ID
15+
4. **SECRET_NAME** - Name of the AWS Secrets Manager secret (e.g., `mewler-liquidation-bot/config`)
16+
- The secret must contain `LIQUIDATOR_EOA` and `LIQUIDATOR_PRIVATE_KEY`
17+
18+
**Optional (recommended for security):**
19+
5. **SECRET_NAME** - Name of the AWS Secrets Manager secret (e.g., `mewler-liquidation-bot/config`)
20+
6. **GLUEX_API_KEY** - Gluex API key (overrides hardcoded value in app.py)
21+
7. **GLUEX_UNIQUE_PID** - Gluex unique PID (overrides hardcoded value in app.py)
22+
8. **MAINNET_RPC_URL** - Mainnet RPC URL (overrides hardcoded value in app.py)
23+
9. **BASE_RPC_URL** - Base chain RPC URL (overrides hardcoded value in app.py)
24+
10. **ARBITRUM_RPC_URL** - Arbitrum RPC URL (overrides hardcoded value in app.py)
25+
11. **SLACK_WEBHOOK_URL** - Slack webhook URL (overrides hardcoded value in app.py)
26+
27+
**Note:** It's recommended to move sensitive values (API keys, RPC URLs with keys) from `cdk/app.py` to GitHub secrets for better security.
28+
29+
### IAM Permissions Required
30+
31+
The AWS credentials need the following permissions:
32+
- CloudFormation (create/update/delete stacks)
33+
- ECS (create/update services, task definitions)
34+
- EC2 (describe VPCs, subnets, security groups)
35+
- IAM (create roles and policies)
36+
- ECR (push/pull container images)
37+
- CloudWatch Logs (create log groups)
38+
- Secrets Manager (read secrets, if using)
39+
40+
### Workflow Steps
41+
42+
1. Checks out the code
43+
2. Sets up Python and Node.js
44+
3. Installs CDK CLI
45+
4. Configures AWS credentials
46+
5. Sets up Python virtual environment and installs CDK dependencies
47+
6. Bootstraps CDK (if needed)
48+
7. Validates the CDK stack with `cdk synth`
49+
8. Deploys the stack with `cdk deploy`
50+
51+
### Manual Trigger
52+
53+
The workflow can also be manually triggered from the Actions tab in GitHub.
54+

.github/workflows/deploy.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Workflow | Deploy backend
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
account:
7+
required: true
8+
type: string
9+
default: "730335381248"
10+
region:
11+
required: true
12+
type: string
13+
default: "ap-northeast-1"
14+
15+
jobs:
16+
liquidator-backend:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 60
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
submodules: "recursive"
24+
25+
- uses: ./.github/actions/deploy-cdk-stack
26+
with:
27+
account: ${{ inputs.account }}
28+
region: ${{ inputs.region }}
29+
stacks: MewlerLiquidationBotStack

.github/workflows/pipelin.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Deploy to Production
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
pull_request:
8+
branches: [main]
9+
10+
workflow_dispatch: {}
11+
12+
permissions:
13+
id-token: write
14+
contents: read
15+
actions: read
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: false
20+
21+
jobs:
22+
deploy:
23+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
24+
name: Deploy | Production
25+
uses: ./.github/workflows/deploy.yaml
26+
with:
27+
account: "730335381248"
28+
region: "ap-northeast-1"
29+
30+
synth:
31+
if: github.event_name == 'pull_request'
32+
name: Dry Run | Production
33+
uses: ./.github/workflows/synth.yaml
34+
with:
35+
account: "730335381248"
36+
region: "ap-northeast-1"

.github/workflows/synth.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Workflow | Deploy backend
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
account:
7+
required: true
8+
type: string
9+
default: "730335381248"
10+
region:
11+
required: true
12+
type: string
13+
default: "ap-northeast-1"
14+
15+
jobs:
16+
liquidator-backend:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 60
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
submodules: "recursive"
24+
25+
- uses: ./.github/actions/cdk-synth
26+
with:
27+
account: ${{ inputs.account }}
28+
region: ${{ inputs.region }}
29+
stacks: MewlerLiquidationBotStack

.github/workflows/test.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ lcov.info
2020

2121
# Virtual env
2222
python-venv/
23-
venv/
23+
venv/
24+
.venv/
25+
cdk/.venv/
2426

2527
# Logs and save state
2628
logs/
@@ -31,4 +33,6 @@ __pycache__/
3133
*.pyo
3234
*.pyd
3335

34-
/redstone_script/node_modules
36+
/redstone_script/node_modulescdk.out/
37+
cdk.context.json
38+
cdk.out

0 commit comments

Comments
 (0)