chore: add cheqd #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: docker | |
on: | |
push: | |
branches: | |
- "master" | |
jobs: | |
docker: | |
strategy: | |
matrix: | |
chain: | |
# TODO: make it dynamic | |
- axone | |
- cheqd | |
- chihuahua | |
- govgen | |
- juno | |
- ki | |
- nois | |
- nolus | |
- teritori | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Go package cache | |
uses: actions/cache@v4 | |
with: | |
path: go-package-cache | |
key: ${{ matrix.platform.go }}-docker-go-package-${{ hashFiles('**/build.yaml') }} | |
restore-keys: | | |
${{ matrix.platform.go }}-docker-go-package- | |
- name: Go build cache | |
uses: actions/cache@v4 | |
with: | |
path: go-build-cache | |
key: ${{ matrix.platform.go }}-docker-go-build-${{ hashFiles('**/build.yaml') }} | |
restore-keys: | | |
${{ matrix.platform.go }}-docker-go-build- | |
- name: Inject go package cache into docker | |
uses: reproducible-containers/buildkit-cache-dance@v3 | |
with: | |
cache-map: | | |
{ | |
"go-package-cache": "/root/go/pkg/mod", | |
"go-build-cache": "/root/.cache/go-build" | |
} | |
- name: Login to GitHub Container Registry | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get version | |
id: version | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -r '.version' './${{ matrix.chain }}/build.yaml' | |
- name: Get go_version | |
id: go_version | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -r '.go_version' './${{ matrix.chain }}/build.yaml' | |
- name: Get chain_repository | |
id: chain_repository | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -r '.chain_repository' './${{ matrix.chain }}/build.yaml' | |
- name: Get daemon_name | |
id: daemon_name | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -r '.daemon_name' './${{ matrix.chain }}/build.yaml' | |
- name: Get daemon_home | |
id: daemon_home | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -r '.daemon_home' './${{ matrix.chain }}/build.yaml' | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ github.repository }}/${{ matrix.chain }} | |
tags: | | |
type=raw,value=latest | |
type=raw,value=${{ steps.version.outputs.result }} | |
- name: Check if image already exist | |
id: image_exists | |
continue-on-error: true | |
uses: cloudposse/[email protected] | |
with: | |
image_name: "${{ github.repository }}/${{ matrix.chain }}" | |
registry: ghcr.io | |
tag: "${{ steps.version.outputs.result }}" | |
# TODO: Check if the directory have a custom Dockerfile | |
# in that case, build a different image | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
if: "steps.image_exists.outcome == 'failure'" | |
with: | |
file: "./Dockerfile" | |
context: ./${{ matrix.chain }} | |
build-args: | | |
CHAIN_NAME=${{ matrix.chain }} | |
VERSION=${{ steps.version.outputs.result }} | |
GO_VERSION=${{ steps.go_version.outputs.result }} | |
CHAIN_REPO=${{ steps.chain_repository.outputs.result }} | |
DAEMON_NAME=${{ steps.daemon_name.outputs.result }} | |
DAEMON_HOME=${{ steps.daemon_home.outputs.result }} | |
push: ${{ github.event_name != 'pull_request' }} | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |