forked from NethermindEth/nethermind
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (59 loc) · 2.03 KB
/
publish-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
name: Publish Docker image
on:
push:
branches: [master, release/*]
paths:
- 'src/Nethermind/**'
workflow_dispatch:
inputs:
image-name:
description: Image name
required: true
default: nethermind
tag:
description: Image tag
required: true
dockerfile:
description: Dockerfile
required: true
default: Dockerfile
build-config:
description: Build configuration
required: true
default: release
type: choice
options:
- release
- debug
jobs:
publish-docker:
name: Publish to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: success()
run: echo "${{ secrets.DOCKER_ACCESS_TOKEN }}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Build and push image to Docker Hub (staging)
run: |
branch=$(echo "${{ github.ref }}" | sed -e "s/refs\/heads\///g")
original_tag=${{ github.event.inputs.tag || '$branch' }}
tag=$(echo "$original_tag" | sed 's/\//-/g') # replace '/' with '-' in tag name
build_timestamp=$(date '+%s')
echo "Building image with tag $tag"
docker buildx build --platform=linux/amd64,linux/arm64 \
-f ${{ github.event.inputs.dockerfile || 'Dockerfile' }} \
-t "nethermindeth/${{ github.event.inputs.image-name || 'nethermind' }}:$tag" \
--build-arg BUILD_CONFIG=${{ github.event.inputs.build-config || 'release' }} \
--build-arg BUILD_TIMESTAMP=$build_timestamp \
--build-arg CI=$CI \
--build-arg COMMIT_HASH=$GITHUB_SHA \
. --push
- name: Clear Docker cache
if: always()
run: rm -f $HOME/.docker/config.json