From ac92bba33998b7f3710e7359a4ba131092708cda Mon Sep 17 00:00:00 2001 From: cristidas Date: Thu, 22 Jun 2023 10:06:04 +0200 Subject: [PATCH 1/5] adding new GH Actions workflows --- .github/workflows/new-aws-prod.yml | 71 +++++++++++++++++++++ .github/workflows/new-aws-staging.yml | 89 +++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 .github/workflows/new-aws-prod.yml create mode 100644 .github/workflows/new-aws-staging.yml diff --git a/.github/workflows/new-aws-prod.yml b/.github/workflows/new-aws-prod.yml new file mode 100644 index 0000000..16210b8 --- /dev/null +++ b/.github/workflows/new-aws-prod.yml @@ -0,0 +1,71 @@ +on: + push: + branches: + - TECH-1747-new-gha-workflow + +name: Deploy to AWS Production + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + env: + AWS_REGION: us-east-1 + ECR_REPO_NAME: cache-prod + ETL_SERVICE_NAME: cache-etl-mainnet-prod + API_SERVICE_NAME: cache-api-mainnet-prod + CLUSTER_NAME: cache-prod + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Extract commit hash + id: vars + shell: bash + run: | + echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + SHA_TAG: ${{ steps.vars.outputs.sha_short }} + LATEST_TAG: latest + ENVIRONMENT_TAG: prod + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + # Build a docker container and + # push it to ECR so that it can + # be deployed to ECS. + docker build -t $ECR_REGISTRY/$ECR_REPO_NAME:$SHA_TAG \ + -t $ECR_REGISTRY/$ECR_REPO_NAME:$LATEST_TAG \ + -t $ECR_REGISTRY/$ECR_REPO_NAME:$ENVIRONMENT_TAG \ + . + docker push $ECR_REGISTRY/$ECR_REPO_NAME --all-tags + + - name: Update ${{ env.ETL_SERVICE_NAME }} ECS service with latest Docker image + id: service-update-etl + run: | + aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.ETL_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION + + - name: Update ${{ env.API_SERVICE_NAME }} ECS service with latest Docker image + id: service-update-api + run: | + aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.API_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION + + - name: Wait for all services to become stable + uses: oryanmoshe/ecs-wait-action@v1.3 + with: + ecs-cluster: ${{ env.CLUSTER_NAME }} + ecs-services: '["${{ env.ETL_SERVICE_NAME }}", "${{ env.API_SERVICE_NAME }}"]' diff --git a/.github/workflows/new-aws-staging.yml b/.github/workflows/new-aws-staging.yml new file mode 100644 index 0000000..0dbb937 --- /dev/null +++ b/.github/workflows/new-aws-staging.yml @@ -0,0 +1,89 @@ +on: + push: + branches: + - TECH-1747-new-gha-workflow + +name: Deploy to AWS Staging + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + env: + AWS_REGION: eu-central-1 + ECR_REPO_NAME: cache-staging + GOERLI_ETL_SERVICE_NAME: cache-etl-goerli-staging + GOERLI_API_SERVICE_NAME: cache-api-goerli-staging + MAINNET_ETL_SERVICE_NAME: cache-etl-mainnet-staging + MAINNET_API_SERVICE_NAME: cache-api-mainnet-staging + CLUSTER_NAME: cache-staging + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Extract commit hash + id: vars + shell: bash + run: | + echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + SHA_TAG: ${{ steps.vars.outputs.sha_short }} + LATEST_TAG: latest + ENVIRONMENT_TAG: staging + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + # Build a docker container and + # push it to ECR so that it can + # be deployed to ECS. + docker build -t $ECR_REGISTRY/$ECR_REPO_NAME:$SHA_TAG \ + -t $ECR_REGISTRY/$ECR_REPO_NAME:$LATEST_TAG \ + -t $ECR_REGISTRY/$ECR_REPO_NAME:$ENVIRONMENT_TAG \ + . + docker push $ECR_REGISTRY/$ECR_REPO_NAME --all-tags + + - name: Update ${{ env.GOERLI_ETL_SERVICE_NAME }} ECS service with latest Docker image + id: service-update-goerli-etl + run: | + aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.GOERLI_ETL_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION + + - name: Update ${{ env.GOERLI_API_SERVICE_NAME }} ECS service with latest Docker image + id: service-update-goerli-api + run: | + aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.GOERLI_API_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION + + - name: Update ${{ env.MAINNET_ETL_SERVICE_NAME }} ECS service with latest Docker image + id: service-update-mainnet-etl + run: | + aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.MAINNET_ETL_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION + + - name: Update ${{ env.MAINNET_API_SERVICE_NAME }} ECS service with latest Docker image + id: service-update-mainnet-api + run: | + aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.MAINNET_API_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION + + - name: Wait for goerli services to become stable + uses: oryanmoshe/ecs-wait-action@v1.3 + with: + ecs-cluster: ${{ env.CLUSTER_NAME }} + ecs-services: '["${{ env.GOERLI_ETL_SERVICE_NAME }}", "${{ env.GOERLI_API_SERVICE_NAME }}"]' + + - name: Wait for mainnet services to become stable + uses: oryanmoshe/ecs-wait-action@v1.3 + with: + ecs-cluster: ${{ env.CLUSTER_NAME }} + ecs-services: '["${{ env.MAINNET_ETL_SERVICE_NAME }}", "${{ env.MAINNET_API_SERVICE_NAME }}"]' From d873c9f870278ae250ccbafd46e9ebdab6aa8c7c Mon Sep 17 00:00:00 2001 From: cristidas Date: Thu, 22 Jun 2023 10:18:33 +0200 Subject: [PATCH 2/5] setting final GHA triggers --- .github/workflows/new-aws-prod.yml | 2 +- .github/workflows/new-aws-staging.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/new-aws-prod.yml b/.github/workflows/new-aws-prod.yml index 16210b8..c2fa43f 100644 --- a/.github/workflows/new-aws-prod.yml +++ b/.github/workflows/new-aws-prod.yml @@ -1,7 +1,7 @@ on: push: branches: - - TECH-1747-new-gha-workflow + - master name: Deploy to AWS Production diff --git a/.github/workflows/new-aws-staging.yml b/.github/workflows/new-aws-staging.yml index 0dbb937..73132e9 100644 --- a/.github/workflows/new-aws-staging.yml +++ b/.github/workflows/new-aws-staging.yml @@ -1,7 +1,7 @@ on: push: branches: - - TECH-1747-new-gha-workflow + - dev name: Deploy to AWS Staging From 8801fcd56e6d7fc2f18b02846bd18e7af0838b51 Mon Sep 17 00:00:00 2001 From: cristidas Date: Thu, 13 Jul 2023 22:21:33 +0200 Subject: [PATCH 3/5] removing old GH Actions workflows --- .github/workflows/aws-prod.yml | 8 +-- .github/workflows/aws-staging.yml | 12 ++-- .github/workflows/new-aws-prod.yml | 71 --------------------- .github/workflows/new-aws-staging.yml | 89 --------------------------- 4 files changed, 10 insertions(+), 170 deletions(-) delete mode 100644 .github/workflows/new-aws-prod.yml delete mode 100644 .github/workflows/new-aws-staging.yml diff --git a/.github/workflows/aws-prod.yml b/.github/workflows/aws-prod.yml index d5adc58..c2fa43f 100644 --- a/.github/workflows/aws-prod.yml +++ b/.github/workflows/aws-prod.yml @@ -11,10 +11,10 @@ jobs: runs-on: ubuntu-latest env: AWS_REGION: us-east-1 - ECR_REPO_NAME: oazo-bcache-prod - ETL_SERVICE_NAME: oazo-bcache-etl-mainnet-prod - API_SERVICE_NAME: oazo-bcache-api-mainnet-prod - CLUSTER_NAME: oazo-bcache-prod + ECR_REPO_NAME: cache-prod + ETL_SERVICE_NAME: cache-etl-mainnet-prod + API_SERVICE_NAME: cache-api-mainnet-prod + CLUSTER_NAME: cache-prod steps: - name: Checkout diff --git a/.github/workflows/aws-staging.yml b/.github/workflows/aws-staging.yml index 0b0108e..73132e9 100644 --- a/.github/workflows/aws-staging.yml +++ b/.github/workflows/aws-staging.yml @@ -11,12 +11,12 @@ jobs: runs-on: ubuntu-latest env: AWS_REGION: eu-central-1 - ECR_REPO_NAME: oazo-bcache-staging - GOERLI_ETL_SERVICE_NAME: oazo-bcache-etl-goerli-staging - GOERLI_API_SERVICE_NAME: oazo-bcache-api-goerli-staging - MAINNET_ETL_SERVICE_NAME: oazo-bcache-etl-mainnet-staging - MAINNET_API_SERVICE_NAME: oazo-bcache-api-mainnet-staging - CLUSTER_NAME: oazo-bcache-staging + ECR_REPO_NAME: cache-staging + GOERLI_ETL_SERVICE_NAME: cache-etl-goerli-staging + GOERLI_API_SERVICE_NAME: cache-api-goerli-staging + MAINNET_ETL_SERVICE_NAME: cache-etl-mainnet-staging + MAINNET_API_SERVICE_NAME: cache-api-mainnet-staging + CLUSTER_NAME: cache-staging steps: - name: Checkout diff --git a/.github/workflows/new-aws-prod.yml b/.github/workflows/new-aws-prod.yml deleted file mode 100644 index c2fa43f..0000000 --- a/.github/workflows/new-aws-prod.yml +++ /dev/null @@ -1,71 +0,0 @@ -on: - push: - branches: - - master - -name: Deploy to AWS Production - -jobs: - deploy: - name: Deploy - runs-on: ubuntu-latest - env: - AWS_REGION: us-east-1 - ECR_REPO_NAME: cache-prod - ETL_SERVICE_NAME: cache-etl-mainnet-prod - API_SERVICE_NAME: cache-api-mainnet-prod - CLUSTER_NAME: cache-prod - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} - - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 - - - name: Extract commit hash - id: vars - shell: bash - run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - - name: Build, tag, and push image to Amazon ECR - id: build-image - env: - SHA_TAG: ${{ steps.vars.outputs.sha_short }} - LATEST_TAG: latest - ENVIRONMENT_TAG: prod - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - run: | - # Build a docker container and - # push it to ECR so that it can - # be deployed to ECS. - docker build -t $ECR_REGISTRY/$ECR_REPO_NAME:$SHA_TAG \ - -t $ECR_REGISTRY/$ECR_REPO_NAME:$LATEST_TAG \ - -t $ECR_REGISTRY/$ECR_REPO_NAME:$ENVIRONMENT_TAG \ - . - docker push $ECR_REGISTRY/$ECR_REPO_NAME --all-tags - - - name: Update ${{ env.ETL_SERVICE_NAME }} ECS service with latest Docker image - id: service-update-etl - run: | - aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.ETL_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION - - - name: Update ${{ env.API_SERVICE_NAME }} ECS service with latest Docker image - id: service-update-api - run: | - aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.API_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION - - - name: Wait for all services to become stable - uses: oryanmoshe/ecs-wait-action@v1.3 - with: - ecs-cluster: ${{ env.CLUSTER_NAME }} - ecs-services: '["${{ env.ETL_SERVICE_NAME }}", "${{ env.API_SERVICE_NAME }}"]' diff --git a/.github/workflows/new-aws-staging.yml b/.github/workflows/new-aws-staging.yml deleted file mode 100644 index 73132e9..0000000 --- a/.github/workflows/new-aws-staging.yml +++ /dev/null @@ -1,89 +0,0 @@ -on: - push: - branches: - - dev - -name: Deploy to AWS Staging - -jobs: - deploy: - name: Deploy - runs-on: ubuntu-latest - env: - AWS_REGION: eu-central-1 - ECR_REPO_NAME: cache-staging - GOERLI_ETL_SERVICE_NAME: cache-etl-goerli-staging - GOERLI_API_SERVICE_NAME: cache-api-goerli-staging - MAINNET_ETL_SERVICE_NAME: cache-etl-mainnet-staging - MAINNET_API_SERVICE_NAME: cache-api-mainnet-staging - CLUSTER_NAME: cache-staging - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} - - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 - - - name: Extract commit hash - id: vars - shell: bash - run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - - name: Build, tag, and push image to Amazon ECR - id: build-image - env: - SHA_TAG: ${{ steps.vars.outputs.sha_short }} - LATEST_TAG: latest - ENVIRONMENT_TAG: staging - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - run: | - # Build a docker container and - # push it to ECR so that it can - # be deployed to ECS. - docker build -t $ECR_REGISTRY/$ECR_REPO_NAME:$SHA_TAG \ - -t $ECR_REGISTRY/$ECR_REPO_NAME:$LATEST_TAG \ - -t $ECR_REGISTRY/$ECR_REPO_NAME:$ENVIRONMENT_TAG \ - . - docker push $ECR_REGISTRY/$ECR_REPO_NAME --all-tags - - - name: Update ${{ env.GOERLI_ETL_SERVICE_NAME }} ECS service with latest Docker image - id: service-update-goerli-etl - run: | - aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.GOERLI_ETL_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION - - - name: Update ${{ env.GOERLI_API_SERVICE_NAME }} ECS service with latest Docker image - id: service-update-goerli-api - run: | - aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.GOERLI_API_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION - - - name: Update ${{ env.MAINNET_ETL_SERVICE_NAME }} ECS service with latest Docker image - id: service-update-mainnet-etl - run: | - aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.MAINNET_ETL_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION - - - name: Update ${{ env.MAINNET_API_SERVICE_NAME }} ECS service with latest Docker image - id: service-update-mainnet-api - run: | - aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.MAINNET_API_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION - - - name: Wait for goerli services to become stable - uses: oryanmoshe/ecs-wait-action@v1.3 - with: - ecs-cluster: ${{ env.CLUSTER_NAME }} - ecs-services: '["${{ env.GOERLI_ETL_SERVICE_NAME }}", "${{ env.GOERLI_API_SERVICE_NAME }}"]' - - - name: Wait for mainnet services to become stable - uses: oryanmoshe/ecs-wait-action@v1.3 - with: - ecs-cluster: ${{ env.CLUSTER_NAME }} - ecs-services: '["${{ env.MAINNET_ETL_SERVICE_NAME }}", "${{ env.MAINNET_API_SERVICE_NAME }}"]' From 1c5630de1e28a5a00ae57cef8dedb118c0989a20 Mon Sep 17 00:00:00 2001 From: Halaprix Date: Wed, 2 Aug 2023 14:33:25 +0200 Subject: [PATCH 4/5] chore: updates after aave v3 sl fix (#218) --- package.json | 2 +- src/config.mainnet.ts | 4 ++++ yarn.lock | 8 ++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3b40cc1..b4aa2b3 100644 --- a/package.json +++ b/package.json @@ -41,12 +41,12 @@ }, "dependencies": { "@google-cloud/bigquery": "^3.0.0", + "@oasisdex/automation": "^1.5.0", "@oasisdex/spock-etl": "^0.1.5", "@oasisdex/spock-graphql-api": "^0.1.2", "@oasisdex/spock-test-utils": "^0.1.1", "@oasisdex/spock-utils": "^0.1.0", "@oasisdex/spock-validation": "^0.1.0", - "@oasisdex/automation": "1.5.0-alpha.8", "abi-decoder": "^1.2.0", "aws-sdk": "^2.1232.0", "bignumber.js": "^8.0.2", diff --git a/src/config.mainnet.ts b/src/config.mainnet.ts index 4ba48a4..da49365 100644 --- a/src/config.mainnet.ts +++ b/src/config.mainnet.ts @@ -200,6 +200,10 @@ const commandMapping = [ command_address: '0x65127d52aaeb356b45c6dcb3da36f4fc6ff738ef', kind: 'aave-stop-loss', }, + { + command_address: '0x52a9bc9a904b9ee6a4714ef883ccf14cb7283b0f', + kind: 'aave-stop-loss', + }, ].map(({ command_address, kind }) => ({ command_address: command_address.toLowerCase(), kind })); const addresses = { diff --git a/yarn.lock b/yarn.lock index 25cf82a..d7d1b1b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -455,10 +455,10 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" -"@oasisdex/automation@1.5.0-alpha.8": - version "1.5.0-alpha.8" - resolved "https://registry.yarnpkg.com/@oasisdex/automation/-/automation-1.5.0-alpha.8.tgz#0660f0bb27cfbfcd18f1d5e959a84855059690c6" - integrity sha512-Q9aHj65/L9yl9c+roctxPsn1SI5g8zFMRwdibgwzsqOOSe6PdBHIxhbXtsfreygLhI8+qd8SWdZd7nx4CISpvg== +"@oasisdex/automation@^1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@oasisdex/automation/-/automation-1.5.0.tgz#b5201f039921f79aee4efe22b77fa460296aec58" + integrity sha512-fqhWTtJwzyLYLgE4y0hCi4W5CwPtQp/+8Vzfdv0fOT86KUBgpvwAvI9Qs4WI0ahCZiGozJE/q+eixSo8/WPN/Q== dependencies: ethers "^5.6.2" From 3054b3a53ede9cd046a4d6a7272224161fd8f020 Mon Sep 17 00:00:00 2001 From: Halaprix Date: Thu, 3 Aug 2023 11:16:46 +0200 Subject: [PATCH 5/5] chore: update automation (#220) --- package.json | 2 +- src/config.mainnet.ts | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index b4aa2b3..7fd95a9 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "dependencies": { "@google-cloud/bigquery": "^3.0.0", - "@oasisdex/automation": "^1.5.0", + "@oasisdex/automation": "^1.5.2", "@oasisdex/spock-etl": "^0.1.5", "@oasisdex/spock-graphql-api": "^0.1.2", "@oasisdex/spock-test-utils": "^0.1.1", diff --git a/src/config.mainnet.ts b/src/config.mainnet.ts index da49365..65ba91e 100644 --- a/src/config.mainnet.ts +++ b/src/config.mainnet.ts @@ -201,7 +201,7 @@ const commandMapping = [ kind: 'aave-stop-loss', }, { - command_address: '0x52a9bc9a904b9ee6a4714ef883ccf14cb7283b0f', + command_address: '0xDC1c84Aac43F21f103e9bD0B091a1B5cc6433554', kind: 'aave-stop-loss', }, ].map(({ command_address, kind }) => ({ command_address: command_address.toLowerCase(), kind })); diff --git a/yarn.lock b/yarn.lock index d7d1b1b..8a2e0e4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -455,10 +455,10 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" -"@oasisdex/automation@^1.5.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@oasisdex/automation/-/automation-1.5.0.tgz#b5201f039921f79aee4efe22b77fa460296aec58" - integrity sha512-fqhWTtJwzyLYLgE4y0hCi4W5CwPtQp/+8Vzfdv0fOT86KUBgpvwAvI9Qs4WI0ahCZiGozJE/q+eixSo8/WPN/Q== +"@oasisdex/automation@^1.5.2": + version "1.5.2" + resolved "https://registry.yarnpkg.com/@oasisdex/automation/-/automation-1.5.2.tgz#99810e1c48f5c02221ed358fb3dcd10a7966b0ca" + integrity sha512-+SRgQU617PGPN/qpPkW0Xz0f5MJ5mXIQVDKLV4ZYNVy6MyZJ9ihT+6ZN98b1hj2BJYAYvv0OQQz+SlMLP/zKMg== dependencies: ethers "^5.6.2"