forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 34
88 lines (79 loc) · 2.28 KB
/
ci.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: CI
env:
FOUNDRY_PROFILE: ci
DOCKER_BUILDKIT: 1
REGISTRY: ghcr.io
REPO: ${{ github.repository_owner }}
on:
push:
branches:
- main
- celestia-develop
pull_request:
branches:
- main
- celestia-develop
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
docker-build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
component:
- op-node
- op-batcher
- op-program
- op-proposer
- op-challenger
- proofs-tools
- op-dispute-mon
- op-conductor
- da-server
- op-supervisor
- cannon
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker Tags
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.REPO }}/${{ matrix.component }}
tags: |
type=sha,format=short
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Save Docker image for testing
if: github.event_name == 'pull_request'
shell: bash
run: |
# Get the first tag from metadata output
FIRST_TAG=$(echo '${{ steps.meta.outputs.tags }}' | head -n 1)
docker save "${FIRST_TAG}" > "/tmp/${{ matrix.component }}.tar"
- name: Upload Docker image
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: docker-${{ matrix.component }}
path: /tmp/${{ matrix.component }}.tar