Skip to content

Commit

Permalink
ci: CircleCI improvements (ethereum#44)
Browse files Browse the repository at this point in the history
- Use build params to conditionally push builds to Docker Hub
- Use env vars to push both the optimism and optimism-history branches
  • Loading branch information
mslipper authored and protolambda committed Sep 6, 2022
1 parent 93afadf commit 28aed75
Showing 1 changed file with 23 additions and 42 deletions.
65 changes: 23 additions & 42 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,30 @@ jobs:
- run:
command: go run build/ci.go lint

build-dockerfile:
push-geth:
docker:
- image: cimg/base:2022.04
parameters:
image-name:
description: Image name
type: string
image-tag:
description: Image tag
type: string
target:
description: Dockerfile target
type: string
default: ""
dockerfile:
description: Dockerfile to use
type: string
steps:
- checkout
- setup_remote_docker:
version: 20.10.12
- run:
name: Build
command: |
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker build -t "ethereumoptimism/<<parameters.image-name>>:<<parameters.image-tag>>" -f <<parameters.dockerfile>> <<#parameters.target>>--target <<parameters.target>><</parameters.target>> .
docker push "ethereumoptimism/<<parameters.image-name>>:<<parameters.image-tag>>"
- when:
condition:
or:
- equal: [ optimism, <<pipeline.git.branch>> ]
- equal: [ optimism-history, <<pipeline.git.branch>> ]
steps:
- checkout
- setup_remote_docker:
version: 20.10.12
- run:
name: Build and push
command: |
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker build -t "ethereumoptimism/reference-optimistic-geth:$CIRCLE_SHA1" -f Dockerfile .
docker tag "ethereumoptimism/reference-optimistic-geth:$CIRCLE_SHA1" "ethereumoptimism/reference-optimistic-geth:$CIRCLE_BRANCH"
docker push "ethereumoptimism/reference-optimistic-geth:$CIRCLE_SHA1"
docker push "ethereumoptimism/reference-optimistic-geth:$CIRCLE_BRANCH"
# Below step is required to prevent CircleCI from barfing on a
# job with no steps
- run: echo 0

workflows:
main:
Expand All @@ -63,21 +60,5 @@ workflows:
name: Run unit tests for geth
- lint-geth:
name: Run linter over geth
- build-dockerfile:
context:
- optimism
filters:
branches:
only:
- optimism
image-name: reference-optimistic-geth
image-tag: latest
dockerfile: Dockerfile
name: Build reference-optimistic-geth develop
- build-dockerfile:
context:
- optimism
image-name: reference-optimistic-geth
image-tag: $CIRCLE_SHA1
dockerfile: Dockerfile
name: Build reference-optimistic-geth per-commit
- push-geth:
name: Push geth

0 comments on commit 28aed75

Please sign in to comment.