Adding CD to geth (#11)

* Adding CD to geth
This commit is contained in:
Will Meister 2020-08-06 12:22:33 -05:00 committed by GitHub
parent 63377e34fa
commit fa42b78228
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 0 deletions

17
.github/scripts/stop-ecs-task.sh vendored Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Invalid number of arguments. Usage: stop-ecs-task.sh <cluster> <service>"
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

50
.github/workflows/dev-ecr-deploy.yml vendored Normal file
View File

@ -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 }}