forked from ChainSafe/ChainBridge
-
Notifications
You must be signed in to change notification settings - Fork 6
52 lines (50 loc) · 1.6 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
# Copyright 2020 ChainSafe Systems
# SPDX-License-Identifier: LGPL-3.0-only
name: Docker build and push
on:
push:
branches:
- master
tags:
- "v*.*.*"
jobs:
build-and-deploy:
name: Docker Deployment
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || contains(github.ref, '/tags/v')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=centrifugeio/chainbridge
GIT_SHORT_COMMIT=`git rev-parse --short HEAD`
TIMESTAMP=`date -u +%Y%m%d%H`
VERSION="${TIMESTAMP}-${GIT_SHORT_COMMIT}"
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
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.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_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 }}