From e137d1a8acd2ff532dff4b8fcaf468da9cd2284a Mon Sep 17 00:00:00 2001 From: MBarwicki Date: Wed, 11 Oct 2023 10:22:23 +0200 Subject: [PATCH] Prod CI/CD --- .github/workflows/prod-build-and-deploy.yml | 68 ++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/.github/workflows/prod-build-and-deploy.yml b/.github/workflows/prod-build-and-deploy.yml index 2a85cc8d..60f43949 100644 --- a/.github/workflows/prod-build-and-deploy.yml +++ b/.github/workflows/prod-build-and-deploy.yml @@ -70,8 +70,11 @@ jobs: REPOSITORY: ${{ env.REPOSITORY }} IMAGE_TAG: ${{ inputs.version }} run: | - docker build --target final -t $REGISTRY/$REPOSITORY:apiserver-$IMAGE_TAG -f ./DockerfileApiServer . + docker build -t $REGISTRY/$REPOSITORY:apiserver-$IMAGE_TAG -f ./DockerfileRocket . docker push $REGISTRY/$REPOSITORY:apiserver-$IMAGE_TAG + outputs: + image-version: ${{ inputs.version }} + BuildReact: runs-on: ubuntu-latest @@ -107,3 +110,66 @@ jobs: name: react-github-actions-build path: ./plugin/build/**/* + + + DeployAPI_Prod: + runs-on: ubuntu-latest + needs: BuildAPI + 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-Starknet-Production + role-session-name: GHStarknet + + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition starknet-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.BuildAPI.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 + + + DeployReact_Prod: + runs-on: ubuntu-latest + needs: BuildReact + steps: + + - 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-Starknet-Production + role-session-name: GHStarknet + + - name: Deploy to S3 + run: aws s3 sync . s3://${{ env.PROD_BUCKET_NAME }} --acl public-read + working-directory: artifact + \ No newline at end of file