Skip to content

Merge branch 'vitest-to-root' into 'dev' #15

Merge branch 'vitest-to-root' into 'dev'

Merge branch 'vitest-to-root' into 'dev' #15

name: Build and Push Relay Docker Image
on:
release:
types: [published]
push:
branches:
- dev
env:
IMAGE_NAME: ghcr.io/rosen-bridge/relay-service
jobs:
build:
name: Build ${{ matrix.platform }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform: ${{ fromJSON(vars.PLATFORM_LIST || '["linux/amd64"]') }}
steps:
- name: Checkout the Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
if: contains(matrix.platform, 'arm')
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,arm
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare for artifact
shell: bash
run: |
platform='${{ matrix.platform }}'
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
- name: Generate Docker Metadata
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.IMAGE_NAME }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
file: ./services/relay/Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest file
shell: bash
run: |
mkdir -p "${{ runner.temp }}/digests"
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest artifact
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
publish:
name: Publish Multi-arch Manifest
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Generate Docker Metadata
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.IMAGE_NAME }}
- name: Login to GHCR Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
env:
IMAGE_NAME: ${{ env.IMAGE_NAME }}
TAGS: ${{ steps.meta.outputs.tags }}
run: |
docker buildx imagetools create \
--annotation "index:org.opencontainers.image.description=Rosen Bridge relay service" \
$(printf ' -t %s' $TAGS) \
$(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *)