From 49802ce06a200ffd2669a9d3141059f3611948e3 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Mon, 2 Nov 2020 16:51:01 -0800 Subject: [PATCH 01/10] workflows: update --- .github/workflows/dev-ecr-deploy.yml | 44 ----------------- .github/workflows/dockerhub-build-push.yml | 20 ++++---- .github/workflows/testnet-ecr-build-push.yml | 50 -------------------- .github/workflows/uat-ecr-build-push.yml | 50 -------------------- 4 files changed, 12 insertions(+), 152 deletions(-) delete mode 100644 .github/workflows/dev-ecr-deploy.yml delete mode 100644 .github/workflows/testnet-ecr-build-push.yml delete mode 100644 .github/workflows/uat-ecr-build-push.yml diff --git a/.github/workflows/dev-ecr-deploy.yml b/.github/workflows/dev-ecr-deploy.yml deleted file mode 100644 index a90614003fa..00000000000 --- a/.github/workflows/dev-ecr-deploy.yml +++ /dev/null @@ -1,44 +0,0 @@ -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 node - uses: actions/setup-node@v1 - - - 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/rollup-microservices - IMAGE_TAG: latest - run: | - docker build -f Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - - - name: Stop existing dev-rollup-microservices ECS task to auto-start task with new image - run: | - ./.github/scripts/stop-ecs-task.sh dev dev-all-in-one - - - name: Logout of Amazon ECR - if: always() - run: docker logout ${{ steps.login-ecr.outputs.registry }} diff --git a/.github/workflows/dockerhub-build-push.yml b/.github/workflows/dockerhub-build-push.yml index a13c0c3649e..8557285089d 100644 --- a/.github/workflows/dockerhub-build-push.yml +++ b/.github/workflows/dockerhub-build-push.yml @@ -3,7 +3,9 @@ name: Build & Push to DockerHub on: push: branches: + - master - testnet + - uat jobs: build: @@ -20,14 +22,16 @@ jobs: - name: Build and push Rollup Services image to DockerHub run: | - docker build -f Dockerfile -t ethereumoptimism/rollup-services:latest . - docker push ethereumoptimism/rollup-services:latest - - - name: Build and push Postgres image to DockerHub - run: | - cd db - docker build -f Dockerfile -t ethereumoptimism/postgres:latest . - docker push ethereumoptimism/postgres:latest + git clone https://github.com/ethereum-optimism/docker.git \ + $HOME/docker + cd $HOME/docker + BRANCH=${GITHUB_REF##*/} + ./build.sh -s batch-submitter -b $BRANCH + if [ $BRANCH == 'master' ]; then + docker push ethereumoptimism/batch-submitter:latest + elif [[ $BRANCH == 'uat' || $BRANCH == 'testnet' ]]; then + docker push ethereumoptimism/batch-submitter:$BRANCH + fi - name: Logout of DockerHub run: docker logout diff --git a/.github/workflows/testnet-ecr-build-push.yml b/.github/workflows/testnet-ecr-build-push.yml deleted file mode 100644 index 81177304a02..00000000000 --- a/.github/workflows/testnet-ecr-build-push.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build & Tag Container, Push testnet build to ECR - -on: - push: - branches: - - testnet - -jobs: - build: - name: Build, Tag & push testnet build to ECR - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Setup node - uses: actions/setup-node@v1 - - - 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: Tag rollback image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: optimism/rollup-microservices - IMAGE_TAG: testnet - run: | - MANIFEST=$(aws ecr batch-get-image --repository-name $ECR_REPOSITORY --image-ids imageTag=$IMAGE_TAG --query 'images[].imageManifest' --output text) - ROLLBACK_TAG="${IMAGE_TAG}_ROLLBACK_$(date +%Y-%m-%d_%H_%M_%S)" - aws ecr put-image --repository-name $ECR_REPOSITORY --image-tag $ROLLBACK_TAG --image-manifest "$MANIFEST" - - - name: Build, tag, and push image to Amazon ECR - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: optimism/rollup-microservices - IMAGE_TAG: testnet - run: | - docker build -f Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - - - name: Logout of Amazon ECR - if: always() - run: docker logout ${{ steps.login-ecr.outputs.registry }} diff --git a/.github/workflows/uat-ecr-build-push.yml b/.github/workflows/uat-ecr-build-push.yml deleted file mode 100644 index fab1550f5c9..00000000000 --- a/.github/workflows/uat-ecr-build-push.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build & Tag Container, Push UAT build to ECR - -on: - push: - branches: - - uat - -jobs: - build: - name: Build, Tag & push UAT build to ECR - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Setup node - uses: actions/setup-node@v1 - - - 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: Tag rollback image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: optimism/rollup-microservices - IMAGE_TAG: uat - run: | - MANIFEST=$(aws ecr batch-get-image --repository-name $ECR_REPOSITORY --image-ids imageTag=$IMAGE_TAG --query 'images[].imageManifest' --output text) - ROLLBACK_TAG="${IMAGE_TAG}_ROLLBACK_$(date +%Y-%m-%d_%H_%M_%S)" - aws ecr put-image --repository-name $ECR_REPOSITORY --image-tag $ROLLBACK_TAG --image-manifest "$MANIFEST" - - - name: Build, tag, and push image to Amazon ECR - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: optimism/rollup-microservices - IMAGE_TAG: uat - run: | - docker build -f Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - - - name: Logout of Amazon ECR - if: always() - run: docker logout ${{ steps.login-ecr.outputs.registry }} From c6e6a8af9d71415f560a1d20f23a1b83dfce5c66 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Mon, 2 Nov 2020 16:57:04 -0800 Subject: [PATCH 02/10] gitflows: update --- .github/workflows/dockerhub-build-push.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/dockerhub-build-push.yml b/.github/workflows/dockerhub-build-push.yml index 8557285089d..c3c2aa1e4f6 100644 --- a/.github/workflows/dockerhub-build-push.yml +++ b/.github/workflows/dockerhub-build-push.yml @@ -14,8 +14,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup node - uses: actions/setup-node@v1 - name: Login to DockerHub Registry run: echo ${{ secrets.DOCKERHUB_ACCESS_TOKEN_SECRET }} | docker login -u ${{ secrets.DOCKERHUB_ACCESS_TOKEN_USERNAME}} --password-stdin @@ -30,7 +28,7 @@ jobs: if [ $BRANCH == 'master' ]; then docker push ethereumoptimism/batch-submitter:latest elif [[ $BRANCH == 'uat' || $BRANCH == 'testnet' ]]; then - docker push ethereumoptimism/batch-submitter:$BRANCH + docker push ethereumoptimism/batch-submitter:$BRANCH fi - name: Logout of DockerHub From fec4b975d650a112f4e3cbace71821c8f4f41971 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Mon, 2 Nov 2020 17:00:07 -0800 Subject: [PATCH 03/10] github workflows: update --- .github/workflows/dockerhub-build-push.yml | 4 ++++ .github/workflows/integration.yml | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dockerhub-build-push.yml b/.github/workflows/dockerhub-build-push.yml index c3c2aa1e4f6..a0d899c9d27 100644 --- a/.github/workflows/dockerhub-build-push.yml +++ b/.github/workflows/dockerhub-build-push.yml @@ -15,6 +15,10 @@ jobs: steps: - uses: actions/checkout@v2 + - uses: webfactory/ssh-agent@v0.4.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_READ }} + - name: Login to DockerHub Registry run: echo ${{ secrets.DOCKERHUB_ACCESS_TOKEN_SECRET }} | docker login -u ${{ secrets.DOCKERHUB_ACCESS_TOKEN_USERNAME}} --password-stdin diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 88484ef48c7..2d3c580064d 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -20,9 +20,6 @@ jobs: with: ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_READ }} - - name: Setup node - uses: actions/setup-node@v1 - - name: Build run: | git clone https://github.com/ethereum-optimism/optimism-integration.git \ From 2e0bb944720be78ac9cb1bd581fe9d33963494ce Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Tue, 3 Nov 2020 07:06:39 -0800 Subject: [PATCH 04/10] gitflows: update for building correct tag --- .github/workflows/integration.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 2d3c580064d..d402e5375f9 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -25,16 +25,13 @@ jobs: git clone https://github.com/ethereum-optimism/optimism-integration.git \ $HOME/optimism-integration \ --recurse-submodules - REPO=$(echo $GITHUB_REPOSITORY | cut -d '/' -f2) - cd $HOME/optimism-integration/$REPO - REMOTE="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git" - git remote add gh $REMOTE - git fetch gh $GITHUB_SHA - git checkout $GITHUB_SHA cd $HOME/optimism-integration + BRANCH=${GITHUB_REF##*/} + ./docker/build.sh -s batch-submitter -b $BRANCH ./docker/build.sh - name: Test run: | cd $HOME/optimism-integration - ./test.sh + BRANCH=${GITHUB_REF##*/} + BATCH_SUBMITTER_TAG=$BRANCH ./test.sh From 5d7778d61e1e57a81af6c0d212c41dd016b6bfe1 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Tue, 3 Nov 2020 07:34:08 -0800 Subject: [PATCH 05/10] gitflows: use head ref --- .github/workflows/integration.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index d402e5375f9..13cf20f88a1 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -26,12 +26,10 @@ jobs: $HOME/optimism-integration \ --recurse-submodules cd $HOME/optimism-integration - BRANCH=${GITHUB_REF##*/} - ./docker/build.sh -s batch-submitter -b $BRANCH + ./docker/build.sh -s batch-submitter -b ${{ .github.head_ref }} ./docker/build.sh - name: Test run: | cd $HOME/optimism-integration - BRANCH=${GITHUB_REF##*/} - BATCH_SUBMITTER_TAG=$BRANCH ./test.sh + BATCH_SUBMITTER_TAG=${{ .github.head_ref }} ./test.sh From 2940cde78ddd663ca5e5b295617312f134617e85 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Tue, 3 Nov 2020 07:42:07 -0800 Subject: [PATCH 06/10] gitflows: env pattern --- .github/workflows/integration.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 13cf20f88a1..b2cee4b0b5b 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -26,10 +26,14 @@ jobs: $HOME/optimism-integration \ --recurse-submodules cd $HOME/optimism-integration - ./docker/build.sh -s batch-submitter -b ${{ .github.head_ref }} + ./docker/build.sh -s batch-submitter -b $GITHUB_BRANCH ./docker/build.sh + env: + GITHUB_BRANCH: ${{ github.head_ref }} - name: Test run: | cd $HOME/optimism-integration - BATCH_SUBMITTER_TAG=${{ .github.head_ref }} ./test.sh + BATCH_SUBMITTER_TAG=$GITHUB_BRANCH ./test.sh + env: + GITHUB_BRANCH: ${{ github.head_ref }} From c6cee9c7cbbaeb2a0150ac9d6efbca1d86722d73 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Tue, 3 Nov 2020 09:05:54 -0800 Subject: [PATCH 07/10] gitflow: simplify --- .github/workflows/integration.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index b2cee4b0b5b..f023335969a 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -26,14 +26,10 @@ jobs: $HOME/optimism-integration \ --recurse-submodules cd $HOME/optimism-integration - ./docker/build.sh -s batch-submitter -b $GITHUB_BRANCH + ./docker/build.sh -s batch-submitter -b $GITHUB_HEAD_REF ./docker/build.sh - env: - GITHUB_BRANCH: ${{ github.head_ref }} - name: Test run: | cd $HOME/optimism-integration - BATCH_SUBMITTER_TAG=$GITHUB_BRANCH ./test.sh - env: - GITHUB_BRANCH: ${{ github.head_ref }} + BATCH_SUBMITTER_TAG=$GITHUB_HEAD_REF ./test.sh From b8d3787606caac6d3929ee38df78a526a003cdd5 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Tue, 3 Nov 2020 09:06:33 -0800 Subject: [PATCH 08/10] github: remove scripts --- .github/scripts/replace-aws-account-id.sh | 4 ---- .github/scripts/stop-ecs-task.sh | 17 ----------------- 2 files changed, 21 deletions(-) delete mode 100755 .github/scripts/replace-aws-account-id.sh delete mode 100755 .github/scripts/stop-ecs-task.sh diff --git a/.github/scripts/replace-aws-account-id.sh b/.github/scripts/replace-aws-account-id.sh deleted file mode 100755 index 7fee21a441a..00000000000 --- a/.github/scripts/replace-aws-account-id.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -sed -iE 's//'"$AWS_ACCOUNT_ID"'/g' ./docker-compose.ci.yml - diff --git a/.github/scripts/stop-ecs-task.sh b/.github/scripts/stop-ecs-task.sh deleted file mode 100755 index 261fe1a6cca..00000000000 --- a/.github/scripts/stop-ecs-task.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/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 From d641ddecd8b5c942b9840705ed1ee810fe3ad438 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Tue, 3 Nov 2020 09:10:43 -0800 Subject: [PATCH 09/10] dockerhub: fix push --- .github/workflows/dockerhub-build-push.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dockerhub-build-push.yml b/.github/workflows/dockerhub-build-push.yml index a0d899c9d27..7d91e425f6c 100644 --- a/.github/workflows/dockerhub-build-push.yml +++ b/.github/workflows/dockerhub-build-push.yml @@ -27,12 +27,11 @@ jobs: git clone https://github.com/ethereum-optimism/docker.git \ $HOME/docker cd $HOME/docker - BRANCH=${GITHUB_REF##*/} - ./build.sh -s batch-submitter -b $BRANCH - if [ $BRANCH == 'master' ]; then + ./build.sh -s batch-submitter -b $GITHUB_HEAD_REF + if [ $GITHUB_HEAD_REF == 'master' ]; then docker push ethereumoptimism/batch-submitter:latest - elif [[ $BRANCH == 'uat' || $BRANCH == 'testnet' ]]; then - docker push ethereumoptimism/batch-submitter:$BRANCH + elif [[ $GITHUB_HEAD_REF == 'uat' || $GITHUB_HEAD_REF == 'testnet' ]]; then + docker push ethereumoptimism/batch-submitter:$GITHUB_HEAD_REF fi - name: Logout of DockerHub From bd7ac8e464aca68ef52a68b22630b3f348b4fe6f Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Tue, 3 Nov 2020 09:20:20 -0800 Subject: [PATCH 10/10] gitflows: echo integration git commit --- .github/workflows/integration.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index f023335969a..58a44c39087 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -26,6 +26,8 @@ jobs: $HOME/optimism-integration \ --recurse-submodules cd $HOME/optimism-integration + GIT_COMMIT=$(git rev-parse HEAD | head -c 8) + echo "optimism-integration $GIT_COMMIT" ./docker/build.sh -s batch-submitter -b $GITHUB_HEAD_REF ./docker/build.sh