Skip to content

chore: default fee value for posting prices 175 unibi (#91) #125

chore: default fee value for posting prices 175 unibi (#91)

chore: default fee value for posting prices 175 unibi (#91) #125

Workflow file for this run

name: Build Docker Image
on:
push:
branches: [ main ]
permissions:
contents: read
packages: write
jobs:
version:
name: Extract Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract.outputs.version }}
steps:
- name: Extract version from tag or branch
id: extract
run: |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
# strip leading "v" if present (e.g., v1.2.3 -> 1.2.3)
VERSION="${GITHUB_REF_NAME#v}"
else
# use branch name (sanitize slashes)
BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}"
VERSION="${BRANCH//\//-}"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
build:
name: Build and Push Pricefeeder Images
needs:
- version
strategy:
fail-fast: true
matrix:
build:
- platform: linux/amd64
runner: ubuntu-24.04
- platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.build.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare env vars
run: |
OS=$(echo "${{ matrix.build.platform }}" | cut -d '/' -f 1)
ARCH=$(echo "${{ matrix.build.platform }}" | cut -d '/' -f 2)
echo "OS=$OS" >> $GITHUB_ENV
echo "ARCH=$ARCH" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR container register
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Go Cache for Docker Build
id: cache
uses: actions/cache@v4
with:
path: |
go-build
go-pkg-mod
key: ${{ runner.os }}-${{ runner.arch }}-pricefeeder-docker-${{ hashFiles('go.sum') }}
- name: Inject cache
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
with:
cache-map: |
{
"go-build": "/root/.cache/go-build",
"go-pkg-mod": "/go/pkg/mod"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: ${{ needs.version.outputs.version }}-${{ env.ARCH }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
push: true
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
build-args: |
VERSION=v${{ needs.version.outputs.version }}
COMMIT=${{ github.sha }}
merge:
name: Create Multi-arch Image
needs:
- version
- build
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ needs.version.outputs.version }}
type=raw,value=latest
- name: Create manifest list and push
run: |
image=$(jq -r '.tags[0]' <<< "$DOCKER_METADATA_OUTPUT_JSON" | cut -d ':' -f 1)
TAGS=$(jq -r '.tags[] | "--tag " + .' <<< "$DOCKER_METADATA_OUTPUT_JSON" | tr '\n' ' ')
docker buildx imagetools create \
$TAGS \
"${image}:${{ needs.version.outputs.version }}-amd64" \
"${image}:${{ needs.version.outputs.version }}-arm64"