-
Notifications
You must be signed in to change notification settings - Fork 91
82 lines (74 loc) · 3.08 KB
/
docker-image-builder.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
---
# Workflow for automatically building and deploying docker images for kurtosis-cdk.
name: Docker Image Builder
on:
workflow_dispatch:
inputs:
zkevm_contracts_version:
description: The ZkEVM contracts version tag to build (e.g., v8.1.0-rc.1-fork.13 or a commit hash)
required: true
patch_version:
description: The version for the patch (e.g., 1, 2 or a string)
required: false
env:
IMAGE_NAME: leovct/zkevm-contracts
POLYCLI_VERSION: v0.1.67 # https://github.com/0xPolygon/polygon-cli/releases/
FOUNDRY_VERSION: nightly-27cabbd6c905b1273a5ed3ba7c10acce90833d76 # https://github.com/foundry-rs/foundry/releases/tag/nightly-27cabbd6c905b1273a5ed3ba7c10acce90833d76 - 2024-11-29
jobs:
zkevm-contracts:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.IMAGE_BUILDER_DOCKERHUB_USERNAME }}
password: ${{ secrets.IMAGE_BUILDER_DOCKERHUB_TOKEN }}
- name: Determine full tag
id: determine_tag
run: |
# Append the fork id to the image tag.
TAG=${{ github.event.inputs.zkevm_contracts_version }}
if [[ $TAG == *-fork.10 ]]; then
# Custom rule to label fork10 tags as fork11.
FULL_TAG="${TAG%-fork.10}-fork.11"
elif [[ $TAG == *pp ]]; then
# Custom rule to label pp tags as fork12.
FULL_TAG="${TAG}-fork.12"
elif [[ $TAG != *-fork.[0-9]* ]]; then
# Custom rule to label undefined tags as fork13.
FULL_TAG="${TAG}-fork.13"
else
FULL_TAG=$TAG
fi
# If provided, append the patch version at the end of the image tag.
PATCH_VERSION=${{ github.event.inputs.patch_version }}
if [[ -n "$PATCH_VERSION" ]]; then
FULL_TAG="${FULL_TAG}-patch.${PATCH_VERSION}"
fi
echo "full_tag=$FULL_TAG" >> $GITHUB_OUTPUT
- name: Check if image already exists
id: check_image
run: |
if docker manifest inspect ${{ env.IMAGE_NAME }}:${{ steps.determine_tag.outputs.full_tag }} > /dev/null 2>&1; then
echo "Image already exists, skipping build."
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "Image does not exist."
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Build image and push to the Docker Hub
if: ${{ steps.check_image.outputs.exists == 'false' }}
uses: docker/build-push-action@v6
with:
context: docker
file: docker/zkevm-contracts.Dockerfile
build-args: |
ZKEVM_CONTRACTS_BRANCH=${{ github.event.inputs.zkevm_contracts_version }}
POLYCLI_VERSION=${{ env.POLYCLI_VERSION }}
FOUNDRY_VERSION=${{ env.FOUNDRY_VERSION }}
push: true
tags: ${{ env.IMAGE_NAME }}:${{ steps.determine_tag.outputs.full_tag }}
cache-from: type=gha
cache-to: type=gha,mode=max