-
Notifications
You must be signed in to change notification settings - Fork 14
88 lines (78 loc) · 2.66 KB
/
docker.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
name: Push Docker Images
# Build & Push builds the finschia docker image on every tag push
on:
push:
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]+-*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-alpha1
env:
registry: docker.io
DOCKER_REPOSITORY: finschia/finschianode
RUNNER_BASE_IMAGE_ALPINE: alpine:3.17
jobs:
docker_build_and_push:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create a context for buildx
run: docker context create buildx
- name: Set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
endpoint: buildx
config-inline: |
[registry."docker.io"]
- name: Login to the registry
uses: docker/login-action@v2
with:
registry: ${{env.registry}}
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
- name: Find go version
id: find_go_version
run: |
GO_VERSION=$(cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_ENV
- name: Find Ostracon version
id: find_ostracon_version
run: |
OST_VERSION=$(go list -m github.com/Finschia/ostracon | sed 's:.* ::')
echo "OST_VERSION=$OST_VERSION" >> $GITHUB_ENV
- name: Parse tag
id: tag
run: |
ref='refs/tags/'
if [[ ${{ github.ref }} == *${ref}* ]]; then
VERSION=$(echo ${{ github.ref_name }} | sed "s/v//")
echo "VERSION=$VERSION" >> $GITHUB_ENV
else
echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV
fi
- name: Extract metadata for docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{env.registry}}/${{env.DOCKER_REPOSITORY}}
tags: |
type=semver,pattern={{version}}
# Build Docker image
- name: Build and push
uses: docker/build-push-action@v4
with:
file: Dockerfile
context: .
push: true
platforms: linux/amd64,linux/arm64
build-args: |
GO_VERSION=${{ env.GO_VERSION }}
RUNNER_IMAGE=${{ env.RUNNER_BASE_IMAGE_ALPINE }}
GIT_VERSION=${{ env.VERSION }}
GIT_COMMIT=${{ github.sha }}
OST_VERSION=${{ env.OST_VERSION }}
tags: |
${{ env.DOCKER_REPOSITORY }}:${{ env.VERSION }}
labels: ${{steps.meta.outputs.labels}}