Skip to content

*: consensus abstraction (#3327) #1782

*: consensus abstraction (#3327)

*: consensus abstraction (#3327) #1782

on:
push:
branches:
- main*
tags:
- 'v*'
name: Build and Publish Docker Image
jobs:
build-docker:
runs-on: charon-ci
name: Build Docker Image
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
with:
driver-opts: "image=moby/buildkit:v0.10.5" # avoid unknown/unknown arch in ghcr
- name: Get app/version.Version from the code
if: github.ref_type == 'branch'
run: echo "APP_VERSION=$(grep 'var version' app/version/version.go | cut -d'"' -f2)" >> $GITHUB_ENV
- name: Define docker image meta data tags
id: meta
uses: docker/metadata-action@v4
with:
images: |
obolnetwork/charon
ghcr.io/obolnetwork/charon
tags: |
# Tag "git short sha" on all git events
type=sha,prefix=
# Tag "next" on git-push-to-main-branch events
type=raw,value=next,event=branch,enable={{is_default_branch}}
# Tag "latest" on git-tag events
type=raw,value=latest,event=tag
# Tag "$APP_VERSION" on git-push-to-branch events
type=raw,value=${{ env.APP_VERSION }},event=branch
# Tag "tag ref" on git-tag events
type=ref,event=tag
- name: Login to Github container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Dockerhub container registry
uses: docker/login-action@v2
with:
username: obolnetwork
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Maybe overwrite app/version.Version with git tag
if: github.ref_type == 'tag'
run: echo 'GO_BUILD_FLAG=-ldflags=-X github.com/obolnetwork/charon/app/version.version=${{ github.ref_name }}' >> $GITHUB_ENV
- uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
build-args: |
GITHUB_SHA=${{ github.sha }}
GO_BUILD_FLAG=${{ env.GO_BUILD_FLAG }}
tags: ${{ steps.meta.outputs.tags }}
- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short=7 ${{ github.sha }})
echo "::set-output name=short_sha::$calculatedSha"
- name: Trigger dev relay deploy job
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.CHARON_K8S_REPO_ACCESS_TOKEN }}
repository: ObolNetwork/obol-infrastructure
event-type: relay-nonprod-deployment
client-payload: '{"relay_name": "relay-dev","relay_version": "${{ steps.vars.outputs.short_sha }}"}'
- name: Trigger charon-K8S deploy job
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.CHARON_K8S_REPO_ACCESS_TOKEN }}
repository: ObolNetwork/charon-k8s
event-type: charon-package-published
client-payload: '{"sha": "${{ github.sha }}"}'