-
Notifications
You must be signed in to change notification settings - Fork 6
108 lines (91 loc) · 4.21 KB
/
deploy-preview.yml
File metadata and controls
108 lines (91 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: GitHub Actions Rain Solver Preview Deployment
on: [push]
concurrency:
group: ${{ github.ref }}-deploy-preview
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
CHANNEL: ${{ github.head_ref || github.ref_name }}
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
TAG_BASE: rainprotocol/arb-bot
jobs:
Deploy-Preview:
runs-on: ubuntu-latest
steps:
- name: 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: Prepare Sushi Lib
run: ./prep-sushi.sh
- name: Build Docker Image
run: docker build -t "$TAG_BASE:$CHANNEL" --build-arg GIT_SHA=${{ github.sha }} --build-arg DOCKER_CHANNEL=$CHANNEL .
# we need to get from/to timestamp because hyperdx by default only shows the last 15 mins logs,
# so if a commit preview has been pushed more than 15 mins ago relative to whenever preview link
# gets opened by someone, it wont show the logs unless user manually increases the timeframe
# from hyperdx gui, so we set the 'from' and 'to' timestamps in the link's query parameters to
# ensure the link always opens within the exact timeframe when the job was executed
- name: Set Preview Link From Timestamp
run: |
# set from timestamps in envs
FROM_TIME=$(date +%s)
# set in github envs as milliseconds
echo "FROM_TIME=${FROM_TIME}000" >> $GITHUB_ENV
# log the timestamp for debug purposes
echo from timestamp: $FROM_TIME \($(date -d @$FROM_TIME)\)
- name: Create GitHub Deployment
id: deployment
uses: bobheadxi/deployments@v1
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: preview
ref: ${{ github.sha }}
- name: Setup Env Vars
run: |
echo "IS_PREVIEW=true" >> .env
echo "PREVIEW_ROUNDS=${{ vars.PREVIEW_ROUNDS }}" >> .env
echo "TRACER_SERVICE_NAME=github-preview-${{ github.sha }}" >> .env
echo "RPC_URL=${{ secrets.PREVIEW_RPC_URL }}" >> .env
echo "HYPERDX_API_KEY=${{ secrets.PREVIEW_HYPERDX_API_KEY }}" >> .env
echo "BOT_WALLET_PRIVATEKEY=${{ secrets.PREVIEW_BOT_WALLET_PRIVATEKEY }}" >> .env
echo "MAX_RATIO=${{ vars.PREVIEW_MAX_RATIO }}" >> .env
echo "SUBGRAPH=${{ vars.PREVIEW_SUBGRAPH }}" >> .env
echo "LIQUIDITY_PROVIDERS=${{ vars.PREVIEW_LIQUIDITY_PROVIDERS }}" >> .env
echo "ARB_ADDRESS=${{ vars.PREVIEW_ARB_ADDRESS }}" >> .env
echo "GENERIC_ARB_ADDRESS=${{ vars.PREVIEW_GENERIC_ARB_ADDRESS }}" >> .env
echo "BOT_MIN_BALANCE=${{ vars.PREVIEW_BOT_MIN_BALANCE }}" >> .env
echo "GAS_PRICE_MULTIPLIER=${{ vars.PREVIEW_GAS_PRICE_MULTIPLIER }}" >> .env
echo "RP_ONLY=${{ vars.PREVIEW_RP_ONLY }}" >> .env
echo "TX_GAS=${{ vars.PREVIEW_TX_GAS }}" >> .env
echo "DISPAIR=${{ vars.PREVIEW_DISPAIR }}" >> .env
echo "MAX_CONCURRENCY=${{ vars.MAX_CONCURRENCY }}" >> .env
- name: Run Rain Solver Docker Image
run: docker run --rm --env-file .env $TAG_BASE:$CHANNEL
# set to timestamp after bot execution has completed
- name: Set Preview Link To Timestamps
run: |
# set to timestamps in envs
TO_TIME=$(date +%s)
# set in github envs as milliseconds
echo "TO_TIME=${TO_TIME}000" >> $GITHUB_ENV
# log the timestamp for debug purposes
echo to timestamp: $TO_TIME \($(date -d @$TO_TIME)\)
- name: Update Deployment Status
uses: bobheadxi/deployments@v1
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
env: preview
status: success
ref: ${{ github.sha }}
override: false
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: https://www.hyperdx.io/search?q=%28%28service%3A%22github-preview-${{ github.sha }}%22%29%29&from=${{ env.FROM_TIME }}&to=${{ env.TO_TIME }}