Skip to content

Commit

Permalink
add github ci build image
Browse files Browse the repository at this point in the history
  • Loading branch information
chaishiqi committed Nov 3, 2024
1 parent b134b2a commit 4e8f852
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: build witness and relayer images

on:
push:
branches: [ "master" ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "master" ]

env:
REGISTRY: ghcr.io

jobs:
build_image:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
name: ["witness","relayer"]
include:
- name: witness
image_name: iotubeproject/witness
dockerfile: Dockerfile.witness
- name: relayer
image_name: iotubeproject/relayer
dockerfile: Dockerfile.relayer
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ matrix.image_name }}

- name: Build and push Docker image ${{ matrix.image_name }}
id: build-and-push
uses: docker/build-push-action@v4
with:
context: ./witness-service
platforms: linux/amd64, linux/arm64
file: ./${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},name-canonical=true

0 comments on commit 4e8f852

Please sign in to comment.