Skip to content

Commit

Permalink
Update ci.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferret-san committed Nov 7, 2024
1 parent e5797d2 commit c20401f
Showing 1 changed file with 36 additions and 50 deletions.
86 changes: 36 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,18 @@ jobs:
packages: write
strategy:
matrix:
component:
# Each component with its Dockerfile path
- component: op-batcher
dockerfile: ./op-batcher/Dockerfile
- component: op-node
dockerfile: ./op-node/Dockerfile
- component: op-proposer
dockerfile: ./op-proposer/Dockerfile
- component: op-challenger
dockerfile: ./op-challenger/Dockerfile
- component: proofs-tools
dockerfile: ./ops/docker/proof-tools/Dockerfile
- component: op-dispute-mon
dockerfile: ./op-dispute-mon/Dockerfile
- component: op-conductor
dockerfile: ./op-conductor/Dockerfile
- component: da-server
dockerfile: ./da-server/Dockerfile
- component: op-supervisor
dockerfile: ./op-supervisor/Dockerfile
- component: cannon
dockerfile: ./cannon/Dockerfile
- component: op-program
dockerfile: ./op-program/Dockerfile
docker_name:
- 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

Expand All @@ -62,39 +50,37 @@ jobs:
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.component }}
tags: |
type=sha,format=short
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
- name: Set build environment
run: |
echo "REGISTRY=${{ env.REGISTRY }}" >> $GITHUB_ENV
echo "REPOSITORY=${{ env.REPO }}" >> $GITHUB_ENV
echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "GIT_DATE=$(git show -s --format='%ct')" >> $GITHUB_ENV
echo "GIT_VERSION=untagged" >> $GITHUB_ENV
echo "IMAGE_TAGS=${{ github.sha }},${{ github.ref_name }}" >> $GITHUB_ENV
echo "PLATFORMS=linux/amd64" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ${{ matrix.component.dockerfile }}
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: Build Docker image
run: |
# Create buildx builder
docker buildx create --driver=docker-container --name=buildx-build --bootstrap --use
# Build using docker-bake.hcl
docker buildx bake \
--progress plain \
--builder=buildx-build \
-f docker-bake.hcl \
${{ matrix.docker_name }}
- 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.component }}.tar"
IMAGE_NAME="${{ env.REGISTRY }}/${{ env.REPO }}/${{ matrix.docker_name }}:${{ github.sha }}"
docker save "$IMAGE_NAME" > "/tmp/${{ matrix.docker_name }}.tar"
- name: Upload Docker image
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: docker-${{ matrix.component.component }}
path: /tmp/${{ matrix.component.component }}.tar
name: docker-${{ matrix.docker_name }}
path: /tmp/${{ matrix.docker_name }}.tar

0 comments on commit c20401f

Please sign in to comment.