Skip to content

push-core-to-main-branch #133

push-core-to-main-branch

push-core-to-main-branch #133

# Copyright 2020 ChainSafe Systems
# SPDX-License-Identifier: LGPL-3.0-only
name: Docker build and push
on:
push:
branches:
# when any if these branches receives a push
- main
- kovan-gorli-dev
- evm-celo-dev
# when any of these versions receive a push
tags:
- "v*.*.*"
# when any releases are created
release:
types:
- created
repository_dispatch:
types: [push-core-to-main-branch]
# list jobs
jobs:
e2e:
name: E2E Tests
strategy:
matrix:
go-version: [ 1.15.x ]
platform: [ ubuntu-latest ]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2.1.6
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Update chainbridge-core, celo-module
run: |
go get -u -v github.com/ChainSafe/chainbridge-core
go get -u -v github.com/ChainSafe/chainbridge-celo-module
- name: Run nodes
run: docker-compose -f ./docker-compose.e2e.yml up -d
- name: Run tests
run: make e2e-test
continue-on-error: true
- run: |
docker ps -a
docker logs relayer
commit-updated-dependencies:
needs: [e2e]
name: Update core-example dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
# allow auto committing with PAT
with:
token: ${{ secrets.CI_WRITE_PAT }}
- name: Setup go environment
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Update chainbridge-core, celo-module
run: |
go get -u -v github.com/ChainSafe/chainbridge-core
go get -u -v github.com/ChainSafe/chainbridge-celo-module
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Updated repo with commit ${{ github.event.client_payload.sha }}
- name: Get merge commit that triggered update
run: echo "Merge commit ${{ github.event.client_payload.sha }}"
build-and-deploy:
needs: [commit-updated-dependencies]
name: Docker Deployment
runs-on: ubuntu-latest
environment: build
# requires these jobs to run first
# if check not passed, job will be skipped
if: github.ref == 'refs/heads/main' || contains(github.ref, '/tags/v') || github.ref == 'refs/heads/kovan-gorli-dev' || github.ref == 'refs/heads/evm-celo-dev'
# list steps
steps:
- name: Checkout
uses: actions/checkout@v2
# prepares docker images
- name: Prepare
id: prep
run: |
# creates local variable of chainbridge docker image
DOCKER_IMAGE=chainsafe/chainbridge-core-example
# creates local variable of commit hash that triggered workflow
BRANCH_ON=$(git branch --show-current)
# creates local variable to hold docker images
TAGS="${DOCKER_IMAGE}:${BRANCH_ON}"
# check if branch/tag that triggered workflow was from tags
if [[ $GITHUB_REF == refs/tags/* ]]; then
# set version
VERSION=${GITHUB_REF#refs/tags/}
# append version to tags
TAGS="${TAGS},${DOCKER_IMAGE}:${VERSION}"
fi
# sets output of step
echo ::set-output name=tags::${TAGS}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}