diff --git a/.github/scripts/stop-ecs-task.sh b/.github/scripts/stop-ecs-task.sh new file mode 100755 index 000000000000..261fe1a6cca4 --- /dev/null +++ b/.github/scripts/stop-ecs-task.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +if [ "$#" -ne 2 ]; then + echo "Invalid number of arguments. Usage: stop-ecs-task.sh " + exit 1 +fi + +cluster=$1 +service=$2 + +tasks=$(aws ecs list-tasks --cluster $cluster --service-name $service) + +task_arn=$(echo $tasks | awk -F\[ '{print $2}' | awk -F\" '{print $2}') + +if [ -n "${task_arn}" ]; then + aws ecs stop-task --cluster $cluster --task $task_arn > /dev/null +fi \ No newline at end of file diff --git a/.github/workflows/dev-ecr-deploy.yml b/.github/workflows/dev-ecr-deploy.yml new file mode 100644 index 000000000000..d744e3469b21 --- /dev/null +++ b/.github/workflows/dev-ecr-deploy.yml @@ -0,0 +1,50 @@ +name: Build & Tag Container, Push to ECR, Deploy to Dev + +on: + push: + branches: + - master + +jobs: + build: + name: Build, Tag & push to ECR, Deploy task + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup golang + uses: actions/setup-go@v2 + with: + go-version: '1.14.2' + + - name: Install & Build + run: make all + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_CI_USER_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_CI_USER_SECRET_ACCESS_KEY }} + aws-region: us-east-2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, tag, and push image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: optimism/geth + IMAGE_TAG: latest + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + +# TODO: Add this when the DEV env is set up +# - name: Stop existing dev-geth ECS task to auto-start task with new image +# run: | +# ./.github/scripts/stop-ecs-task.sh dev-geth geth + + - name: Logout of Amazon ECR + if: always() + run: docker logout ${{ steps.login-ecr.outputs.registry }}