Skip to content

Commit

Permalink
feat: add deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
AquiGorka committed May 16, 2024
1 parent 33f3d3f commit b9139d0
Show file tree
Hide file tree
Showing 2 changed files with 217 additions and 0 deletions.
148 changes: 148 additions & 0 deletions .github/workflows/devnet_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Deploy Devnet

on:
push:
branches:
- main
- gorka/isolate-components

jobs:
contracts:
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
context: app

- name: Compile and deploy contracts
id: compile-and-deploy-contracts
env:
WEB3_RPC_URL: ${{ secrets.WEB3_RPC_URL }}
run: |
echo "# TODO"
# solver-build-deploy:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# context: app

# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: us-east-1

# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v1
# with:
# mask-password: 'true'

# - name: Solver build, tag, and push image to Amazon ECR
# id: build-image
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# ECR_REPOSITORY_SOLVER: ${{ secrets.ECR_REPOSITORY_SOLVER }}
# CLOUDFLARE_TOKEN_SOLVER: ${{ secrets.CLOUDFLARE_TOKEN_SOLVER }}
# run: |
# docker build \
# -t $ECR_REPOSITORY_SOLVER \
# -f ./docker/solver/Dockerfile \
# --build-arg="expose_via=cloudflare" \
# --build-arg="cloudflare_token=${CLOUDFLARE_TOKEN_SOLVER}"\
# --build-arg doppler_config=devnet \
# .
# docker tag $ECR_REPOSITORY_SOLVER:latest $ECR_REGISTRY/$ECR_REPOSITORY_SOLVER:latest
# docker push $ECR_REGISTRY/$ECR_REPOSITORY_SOLVER:latest

# - name: Solver deploy to EC2 instance
# uses: appleboy/ssh-action@master
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# ECR_REPOSITORY_SOLVER: ${{ secrets.ECR_REPOSITORY_SOLVER }}
# DOPPLER_TOKEN_SOLVER: ${{ secrets.DOPPLER_TOKEN_SOLVER }}
# with:
# host: ${{ secrets.EC2_HOST_SOLVER }}
# username: ${{ secrets.EC2_USERNAME_SOLVER }}
# key: ${{ secrets.EC2_PRIVATE_KEY_SOLVER }}
# envs: ECR_REGISTRY, ECR_REPOSITORY_SOLVER
# script_stop: true
# script: |
# docker stop solver || true
# docker rm solver || true
# aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_REGISTRY
# docker system prune -af
# docker pull $ECR_REGISTRY/$ECR_REPOSITORY_SOLVER:latest
# docker run \
# -d \
# --restart always \
# --name solver \
# -e DOPPLER_TOKEN=$DOPPLER_TOKEN_SOLVER \
# $ECR_REGISTRY/$ECR_REPOSITORY_SOLVER:latest

# job-creator-build-deploy:
# needs: [solver]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# context: app

# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: us-east-1

# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v1
# with:
# mask-password: 'true'

# - name: Job creator build, tag, and push image to Amazon ECR
# id: build-image
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# ECR_REPOSITORY_JOB_CREATOR: ${{ secrets.ECR_REPOSITORY_JOB_CREATOR }}
# run: |
# docker build \
# -t $ECR_REPOSITORY_JOB_CREATOR \
# -f ./docker/job-creator/Dockerfile \
# --build-arg="expose_via=cloudflare" \
# --build-arg doppler_config=devnet \
# .
# docker tag $ECR_REPOSITORY_JOB_CREATOR:latest $ECR_REGISTRY/$ECR_REPOSITORY_JOB_CREATOR:latest
# docker push $ECR_REGISTRY/$ECR_REPOSITORY_JOB_CREATOR:latest

# - name: Job creator deploy to EC2 instance
# uses: appleboy/ssh-action@master
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# ECR_REPOSITORY_JOB_CREATOR: ${{ secrets.ECR_REPOSITORY_JOB_CREATOR }}
# DOPPLER_TOKEN_JOB_CREATOR: ${{ secrets.DOPPLER_TOKEN_JOB_CREATOR }}
# with:
# host: ${{ secrets.EC2_HOST_JOB_CREATOR }}
# username: ${{ secrets.EC2_USERNAME_JOB_CREATOR }}
# key: ${{ secrets.EC2_PRIVATE_KEY_JOB_CREATOR }}
# envs: ECR_REGISTRY, ECR_REPOSITORY_JOB_CREATOR
# script_stop: true
# script: |
# docker stop job-creator || true
# docker rm job-creator || true
# aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_REGISTRY
# docker system prune -af
# docker pull $ECR_REGISTRY/$ECR_REPOSITORY_JOB_CREATOR:latest
# docker run \
# -d \
# --restart always \
# --name job-creator \
# -e DOPPLER_TOKEN=$DOPPLER_TOKEN_JOB_CREATOR \
# $ECR_REGISTRY/$ECR_REPOSITORY_JOB_CREATOR:latest
69 changes: 69 additions & 0 deletions .github/workflows/devnet_deploy_chain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Deploy Devnet chain

on: workflow_dispatch

jobs:
chain-build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
context: app

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'

- name: Chain build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY_CHAIN: ${{ secrets.ECR_REPOSITORY_CHAIN }}
CLOUDFLARE_TOKEN_HTTP: ${{ secrets.CLOUDFLARE_TOKEN_HTTP }}
CLOUDFLARE_TOKEN_WS: ${{ secrets.CLOUDFLARE_TOKEN_WS }}
ADMIN_ADDRESS: ${{ secrets.ADMIN_ADDRESS }}
run: |
docker build \
-t $ECR_REPOSITORY_CHAIN \
-f ./docker/chain/Dockerfile \
--build-arg="admin_address=${ADMIN_ADDRESS}" \
--build-arg="expose_via=cloudflare" \
--build-arg="cloudflare_token_http=${CLOUDFLARE_TOKEN_HTTP}"\
--build-arg="cloudflare_token_ws=${CLOUDFLARE_TOKEN_WS}"\
.
docker tag $ECR_REPOSITORY_CHAIN:latest $ECR_REGISTRY/$ECR_REPOSITORY_CHAIN:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY_CHAIN:latest
- name: Chain deploy to EC2 instance
uses: appleboy/ssh-action@master
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY_CHAIN: ${{ secrets.ECR_REPOSITORY_CHAIN }}
with:
host: ${{ secrets.EC2_HOST_CHAIN }}
username: ${{ secrets.EC2_USERNAME_CHAIN }}
key: ${{ secrets.EC2_PRIVATE_KEY_CHAIN }}
envs: ECR_REGISTRY, ECR_REPOSITORY_CHAIN
script_stop: true
script: |
docker stop chain || true
docker rm chain || true
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_REGISTRY
docker system prune -af
docker pull $ECR_REGISTRY/$ECR_REPOSITORY_CHAIN:latest
docker run \
-d \
--restart always \
--name chain \
-v /data/chain:/data/chain \
$ECR_REGISTRY/$ECR_REPOSITORY_CHAIN:latest

0 comments on commit b9139d0

Please sign in to comment.