Skip to content

Merge branch 'dev' of https://github.com/TrainProtocol/solver into dev #23

Merge branch 'dev' of https://github.com/TrainProtocol/solver into dev

Merge branch 'dev' of https://github.com/TrainProtocol/solver into dev #23

Workflow file for this run

name: API
on:
push:
branches: [ main, dev ]
paths:
- 'csharp/**'
- '.github/workflows/api.yml'
pull_request:
branches: [ main, dev ]
paths:
- 'csharp/**'
- '.github/workflows/api.yml'
release:
types: [published, created]
env:
DOCKER_IMAGE: trainprotocol/train-solver-api
DOTNET_VERSION: 8
jobs:
build-and-push:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'release'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Format version
id: format_version
run: |
commitHash=${GITHUB_SHA:0:7}
ts=$(date +%s)
version=$commitHash-$ts
echo "VERSION=$version" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: csharp/src/API/Dockerfile
push: true
build-args: |
DOTNET_VERSION=${{ env.DOTNET_VERSION }}
tags: |
${{ env.DOCKER_IMAGE }}:${{ github.ref_name }}-${{ env.VERSION }}
${{ env.DOCKER_IMAGE }}:${{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max