Skip to content

Commit

Permalink
add docker push workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes committed May 13, 2024
1 parent 42a7f63 commit d650817
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: docker

on:
push:
branches:
- main
tags:
- v*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
IMAGE_NAME: ${{ github.repository_owner}}/mev-rs

jobs:
extract-version:
runs-on: ubuntu-22.04
steps:
- name: Extract version (if main)
if: github.event.ref == 'refs/heads/main'
run: |
echo "VERSION=latest" >> $GITHUB_ENV
- name: Extract version (if tagged release)
if: startsWith(github.event.ref, 'refs/tags')
run: |
echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
outputs:
VERSION: ${{ env.VERSION }}
build-docker:
name: build-docker-${{ matrix.binary }}
runs-on: ubuntu-22.04
strategy:
matrix:
binary: [x86_64]
include:
- profile: maxperf

needs: [extract-version]
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
- name: Read toolchain file
id: rust-toolchain
run: |
RUST_TOOLCHAIN=$(grep 'channel' rust-toolchain.toml | awk '{split($0,a," = "); print a[2]}' | tr -d '"')
echo "RUST_TOOLCHAIN=$RUST_TOOLCHAIN" >> $GITHUB_OUTPUT
shell: bash

- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.rust-toolchain.outputs.RUST_TOOLCHAIN }}
- name: Dockerhub login
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
- name: Build binary
run: |
cargo install --path bin/mev --locked --profile maxperf
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
file: ./Dockerfile
context: .
platforms: linux/x86_64
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}

0 comments on commit d650817

Please sign in to comment.