-
Notifications
You must be signed in to change notification settings - Fork 39
56 lines (52 loc) · 2.07 KB
/
docker_build.yaml
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
name: Build and push Docker image
on:
push:
branches: [ "main" ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build-push-image:
name: Build and push Docker image
runs-on: [self-hosted, ci-runner]
steps:
- uses: actions/checkout@v3
- name: Set outputs
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Login to GAR
run: |
gcloud auth configure-docker us-docker.pkg.dev -q
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Generate build ID for Flux Image Automation
id: set_version
run: |
if [[ ${{ github.ref }} =~ "refs/tags" ]]; then
echo "::set-output name=image_tag_suffix::${GITHUB_REF#refs/*/}"
else
sha=$(git rev-parse --short HEAD)
ts=$(date +%s%N | cut -b1-13)
echo "::set-output name=image_tag_suffix::${sha}-${ts}"
fi
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build_push_tag
uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile
push: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }}
tags: |
"matterlabs/zksync-bft:latest"
"matterlabs/zksync-bft:${{ steps.set_version.outputs.image_tag_suffix }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/zksync-bft:latest"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/zksync-bft:${{ steps.set_version.outputs.image_tag_suffix }}"
- name: Print image digest
run: echo ${{ steps.docker_build.outputs.digest }}