This file contains hidden or 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
| 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 }} |