-
Notifications
You must be signed in to change notification settings - Fork 48
132 lines (128 loc) · 4.49 KB
/
coordinator-build-and-publish.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
name: coordinator-build
on:
workflow_call:
inputs:
commit_tag:
required: true
type: string
develop_tag:
required: true
type: string
image_name:
required: true
type: string
push_image:
required: false
type: boolean
default: false
secrets:
DOCKERHUB_USERNAME:
required: false
DOCKERHUB_TOKEN:
required: false
workflow_dispatch:
inputs:
commit_tag:
description: 'Image tag'
required: true
type: string
develop_tag:
description: 'Image tag will be "develop" if target branch is main'
required: true
type: choice
options:
- develop
default: 'develop'
image_name:
description: 'Image name'
required: true
type: string
default: 'consensys/linea-coordinator'
push_image:
description: 'Toggle whether to push image to docker registry'
required: false
type: boolean
default: true
concurrency:
group: coordinator-build-and-publish-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
build-and-publish:
runs-on: gha-runner-scale-set-ubuntu-22.04-amd64-med
name: Coordinator build
env:
COMMIT_TAG: ${{ inputs.commit_tag }}
DEVELOP_TAG: ${{ inputs.develop_tag }}
IMAGE_NAME: ${{ inputs.image_name }}
PUSH_IMAGE: ${{ inputs.push_image }}
TAGS: ${{ inputs.image_name }}:${{ inputs.commit_tag }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- name: Set develop tag if main branch
if: ${{ github.ref == 'refs/heads/main' }}
run: |
echo "TAGS=${{ env.IMAGE_NAME }}:${{ env.COMMIT_TAG }},${{ env.IMAGE_NAME }}:${{ env.DEVELOP_TAG }}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b #v4.5.0
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 #v4.2.1
- name: Build dist
run: |
./gradlew coordinator:app:installDist --no-daemon
- name: Login to Docker Hub
if: ${{ env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx - local
id: buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: coordinator
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
- name: Build for testing
uses: docker/build-push-action@v6
if: ${{ env.PUSH_IMAGE == 'false' }}
with:
context: .
build-contexts: libs=./coordinator/app/build/install/coordinator/lib
file: ./coordinator/Dockerfile
platforms: linux/amd64
load: true
push: false
tags: ${{ env.IMAGE_NAME }}:${{ env.COMMIT_TAG }}
- name: Save Docker image as artifact
if: ${{ env.PUSH_IMAGE == 'false' }}
run: |
docker save ${{ env.IMAGE_NAME }}:${{ env.COMMIT_TAG }} | gzip > linea-coordinator-docker-image.tar.gz
shell: bash
- name: Upload Docker image artifact
if: ${{ env.PUSH_IMAGE == 'false' }}
uses: actions/upload-artifact@v4
with:
name: linea-coordinator
path: linea-coordinator-docker-image.tar.gz
- name: Build & push
uses: docker/build-push-action@v6
if: ${{ env.PUSH_IMAGE == 'true' || github.event_name == 'workflow_dispatch' }}
with:
context: .
build-contexts: libs=./coordinator/app/build/install/coordinator/lib
file: ./coordinator/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.TAGS }}
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max