-
Notifications
You must be signed in to change notification settings - Fork 15
134 lines (124 loc) · 4.18 KB
/
docker-build-and-push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# 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/[email protected]
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 }}