From 2fbf137c05b2b61f39fe6e89f5b3e8221ab8cfae Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Wed, 13 Jan 2021 12:46:41 +0100 Subject: [PATCH 1/4] add docker deployment action --- .github/workflows/docker.yml | 54 ++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 9 ++++++ 2 files changed, 63 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000000..43f58870ede --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,54 @@ +name: Build & Push +# Build & Push builds the simapp docker image on every push to master and +# and pushes the image to https://hub.docker.com/r/interchainio/simapp/tags +on: + push: + branches: + - master + tags: + - "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10 + - "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5 + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + with: + fetch-depth: 0 + + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=tendermint/gaia + VERSION=noop + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + elif [[ $GITHUB_REF == refs/heads/* ]]; then + VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') + if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then + VERSION=latest + fi + fi + TAGS="${DOCKER_IMAGE}:${VERSION}" + if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION}" + fi + echo ::set-output name=version::${VERSION} + echo ::set-output name=tags::${TAGS} + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Publish to Docker Hub + uses: docker/build-push-action@v2 + with: + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.prep.outputs.tags }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8d795adfdae..2f2f4f2283d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,3 +49,12 @@ jobs: file: ./coverage.txt # optional fail_ci_if_error: true if: "env.GIT_DIFF != ''" + + docker-build: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - name: build docker image + run: | + docker build --pull --rm -f "Dockerfile" -t gaia:latest "." From 55410eddee0082063f49f6088486e13a51a1f896 Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Wed, 13 Jan 2021 12:58:22 +0100 Subject: [PATCH 2/4] build dont push --- .github/workflows/docker.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 43f58870ede..750f2e9d0be 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,6 +2,7 @@ name: Build & Push # Build & Push builds the simapp docker image on every push to master and # and pushes the image to https://hub.docker.com/r/interchainio/simapp/tags on: + pull_request: push: branches: - master @@ -20,7 +21,7 @@ jobs: - name: Prepare id: prep run: | - DOCKER_IMAGE=tendermint/gaia + DOCKER_IMAGE=tendermint/gaia` VERSION=noop if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/} From 06a534957efbbdcd68af1b43447bbc1546863827 Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Wed, 13 Jan 2021 14:08:35 +0100 Subject: [PATCH 3/4] fix script --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 750f2e9d0be..f30ad24e2e0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -21,7 +21,7 @@ jobs: - name: Prepare id: prep run: | - DOCKER_IMAGE=tendermint/gaia` + DOCKER_IMAGE=tendermint/gaia VERSION=noop if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/} From 811a5057b95906e36d1ed57738d3c9c4e521d88a Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Wed, 13 Jan 2021 14:09:12 +0100 Subject: [PATCH 4/4] remove extra docker build --- .github/workflows/test.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f2f4f2283d..8d795adfdae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,12 +49,3 @@ jobs: file: ./coverage.txt # optional fail_ci_if_error: true if: "env.GIT_DIFF != ''" - - docker-build: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v2 - - name: build docker image - run: | - docker build --pull --rm -f "Dockerfile" -t gaia:latest "."