From 1e49243d0aa11e18b35cfaa171f64c54207f0e67 Mon Sep 17 00:00:00 2001 From: Asiya-Yunusa Date: Mon, 6 Nov 2023 19:50:07 +0100 Subject: [PATCH 1/3] Adding API and Remix deploy workflow for production --- .github/workflows/api-deploy.yml | 81 +++++++++++++++--------------- .github/workflows/remix-deploy.yml | 39 +++++++------- 2 files changed, 61 insertions(+), 59 deletions(-) diff --git a/.github/workflows/api-deploy.yml b/.github/workflows/api-deploy.yml index 0a15fd06..27aa702d 100644 --- a/.github/workflows/api-deploy.yml +++ b/.github/workflows/api-deploy.yml @@ -3,6 +3,7 @@ on: push: branches: - develop + - zksync-production-setup # paths: # - 'api/**' @@ -63,7 +64,7 @@ jobs: aws-region: us-east-2 role-to-assume: arn:aws:iam::599564732950:role/Aws-GH-Action-Assume-Role-ZKSync role-session-name: GHZKSync - + - name: Login to Amazon ECR id: login-ecr uses: aws-actions/amazon-ecr-login@v1 @@ -75,21 +76,21 @@ jobs: # curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y # rustup update # rustup component add clippy -# rustup install nightly +# rustup install nightly # sudo apt install musl-tools # rustup target add x86_64-unknown-linux-musl - + # - name: Toolchains info # run: | # cargo --version --verbose # rustc --version -# cargo clippy --version +# cargo clippy --version # - name: Build # run: | # cd api -# cargo build --target=x86_64-unknown-linux-musl +# cargo build --target=x86_64-unknown-linux-musl # ls ./target/debug/ -al - name: Build, tag, and push docker image to Amazon ECR @@ -130,7 +131,7 @@ jobs: # inject the expected React package URL for CORS logic environment-variables: | RUST_LOG=INFO - VITE_URL=https://zksync-plugin.nethermind.dev + VITE_URL=https://zksync-cairo-remix-dev.nethermind.io PROMTAIL_USERNAME=${{secrets.PROMTAIL_USERNAME}} PROMTAIL_PASSWORD=${{secrets.PROMTAIL_PASSWORD}} @@ -141,40 +142,40 @@ jobs: service: ${{ env.DEV_SERVICE_NAME }} cluster: ${{ env.DEV_CLUSTER }} wait-for-service-stability: true - # Deploy_Prod: - # if: github.ref == 'refs/heads/zksync-production-setup' - # runs-on: ubuntu-latest - # needs: Build - # steps: - # - name: Configure AWS credentials - # uses: aws-actions/configure-aws-credentials@v1 - # with: - # aws-region: us-east-2 - # role-to-assume: arn:aws:iam::228016254426:role/Aws-GH-Action-Assume-Role-ZKSync-Production - # role-session-name: GHZKSync + Deploy_Prod: + if: github.ref == 'refs/heads/zksync-production-setup' + runs-on: ubuntu-latest + needs: Build + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-region: us-east-2 + role-to-assume: arn:aws:iam::228016254426:role/Aws-GH-Action-Assume-Role-ZKSync-Production + role-session-name: GHZKSync - # - name: Download task definition - # run: | - # aws ecs describe-task-definition --task-definition zksync-remix-production-rocket --query taskDefinition > task-definition.json + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition zksync-remix-production-rocket --query taskDefinition > task-definition.json - # - name: Fill in the new image ID in the Amazon ECS task definition - # id: task-def - # uses: aws-actions/amazon-ecs-render-task-definition@v1 - # with: - # task-definition: task-definition.json - # container-name: "rocket" - # image: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:apiserver-${{ needs.Build.outputs.image-version }} #${{ github.run_number }} - # # inject the expected React package URL for CORS logic - # environment-variables: | - # RUST_LOG=INFO - # VITE_URL=https://cairo-remix-dev.nethermind.io - # PROMTAIL_USERNAME=${{secrets.PROMTAIL_USERNAME}} - # PROMTAIL_PASSWORD=${{secrets.PROMTAIL_PASSWORD}} + - name: Fill in the new image ID in the Amazon ECS task definition + id: task-def + uses: aws-actions/amazon-ecs-render-task-definition@v1 + with: + task-definition: task-definition.json + container-name: "rocket" + image: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:apiserver-${{ needs.Build.outputs.image-version }} #${{ github.run_number }} + # inject the expected React package URL for CORS logic + environment-variables: | + RUST_LOG=INFO + VITE_URL=https://cairo-remix-dev.nethermind.io + PROMTAIL_USERNAME=${{secrets.PROMTAIL_USERNAME}} + PROMTAIL_PASSWORD=${{secrets.PROMTAIL_PASSWORD}} - # - name: Deploy Amazon ECS task definition - # uses: aws-actions/amazon-ecs-deploy-task-definition@v1 - # with: - # task-definition: ${{ steps.task-def.outputs.task-definition }} - # service: ${{ env.PROD_SERVICE_NAME }} - # cluster: ${{ env.PROD_CLUSTER }} - # wait-for-service-stability: true + - name: Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + service: ${{ env.PROD_SERVICE_NAME }} + cluster: ${{ env.PROD_CLUSTER }} + wait-for-service-stability: true diff --git a/.github/workflows/remix-deploy.yml b/.github/workflows/remix-deploy.yml index dbc63cbf..7a3308b0 100644 --- a/.github/workflows/remix-deploy.yml +++ b/.github/workflows/remix-deploy.yml @@ -3,6 +3,7 @@ on: push: branches: - develop + - zksync-production-setup # paths: # - 'plugin/**' @@ -104,25 +105,25 @@ jobs: run: aws s3 sync . s3://${{ env.BUCKET_NAME }} --acl public-read working-directory: artifact - # Deploy_Prod: - # if: github.ref == 'refs/heads/zksync-production-setup' - # runs-on: ubuntu-latest - # needs: Build - # steps: + Deploy_Prod: + if: github.ref == 'refs/heads/zksync-production-setup' + runs-on: ubuntu-latest + needs: Build + steps: - # - name: Get artifact - # uses: actions/download-artifact@v3 - # with: - # name: react-github-actions-build - # path: artifact + - name: Get artifact + uses: actions/download-artifact@v3 + with: + name: react-github-actions-build + path: artifact - # - name: Configure AWS credentials - # uses: aws-actions/configure-aws-credentials@v1 - # with: - # aws-region: us-east-2 - # role-to-assume: arn:aws:iam::228016254426:role/Aws-GH-Action-Assume-Role-ZKSync-Production - # role-session-name: GHZKSync + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-region: us-east-2 + role-to-assume: arn:aws:iam::228016254426:role/Aws-GH-Action-Assume-Role-ZKSync-Production + role-session-name: GHZKSync - # - name: Deploy to S3 - # run: aws s3 sync . s3://${{ env.PROD_BUCKET_NAME }} --acl public-read - # working-directory: artifact + - name: Deploy to S3 + run: aws s3 sync . s3://${{ env.PROD_BUCKET_NAME }} --acl public-read + working-directory: artifact From cf10e23c90a002529ebe9a7dacdc92b727b7d9d7 Mon Sep 17 00:00:00 2001 From: Asiya-Yunusa Date: Sat, 11 Nov 2023 12:25:56 +0100 Subject: [PATCH 2/3] Adding production build for API and remix deploy --- .github/workflows/api-deploy.yml | 4 ++-- .github/workflows/remix-deploy.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/api-deploy.yml b/.github/workflows/api-deploy.yml index 27aa702d..33780206 100644 --- a/.github/workflows/api-deploy.yml +++ b/.github/workflows/api-deploy.yml @@ -3,7 +3,7 @@ on: push: branches: - develop - - zksync-production-setup + - production # paths: # - 'api/**' @@ -143,7 +143,7 @@ jobs: cluster: ${{ env.DEV_CLUSTER }} wait-for-service-stability: true Deploy_Prod: - if: github.ref == 'refs/heads/zksync-production-setup' + if: github.ref == 'refs/heads/production' runs-on: ubuntu-latest needs: Build steps: diff --git a/.github/workflows/remix-deploy.yml b/.github/workflows/remix-deploy.yml index 7a3308b0..1f782fe2 100644 --- a/.github/workflows/remix-deploy.yml +++ b/.github/workflows/remix-deploy.yml @@ -3,7 +3,7 @@ on: push: branches: - develop - - zksync-production-setup + - production # paths: # - 'plugin/**' @@ -106,7 +106,7 @@ jobs: working-directory: artifact Deploy_Prod: - if: github.ref == 'refs/heads/zksync-production-setup' + if: github.ref == 'refs/heads/production' runs-on: ubuntu-latest needs: Build steps: From 9223d59c18c4c1e0ea3522889e5d300febf79c44 Mon Sep 17 00:00:00 2001 From: Asiya-Yunusa Date: Sat, 11 Nov 2023 12:30:30 +0100 Subject: [PATCH 3/3] Updating build paths and branches --- .github/workflows/api-deploy.yml | 7 +++---- .github/workflows/remix-deploy.yml | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/api-deploy.yml b/.github/workflows/api-deploy.yml index 33780206..d6289644 100644 --- a/.github/workflows/api-deploy.yml +++ b/.github/workflows/api-deploy.yml @@ -3,9 +3,8 @@ on: push: branches: - develop - - production - # paths: - # - 'api/**' + paths: + - 'api/**' permissions: id-token: write @@ -143,7 +142,7 @@ jobs: cluster: ${{ env.DEV_CLUSTER }} wait-for-service-stability: true Deploy_Prod: - if: github.ref == 'refs/heads/production' + if: github.ref == 'refs/heads/zksync-production-setup' runs-on: ubuntu-latest needs: Build steps: diff --git a/.github/workflows/remix-deploy.yml b/.github/workflows/remix-deploy.yml index 1f782fe2..a7108c4c 100644 --- a/.github/workflows/remix-deploy.yml +++ b/.github/workflows/remix-deploy.yml @@ -3,9 +3,8 @@ on: push: branches: - develop - - production - # paths: - # - 'plugin/**' + paths: + - 'plugin/**' env: NODE_VERSION: '20.x' @@ -106,7 +105,7 @@ jobs: working-directory: artifact Deploy_Prod: - if: github.ref == 'refs/heads/production' + if: github.ref == 'refs/heads/zksync-production-setup' runs-on: ubuntu-latest needs: Build steps: