Skip to content

refactor: replace service by containers (#32) #97

refactor: replace service by containers (#32)

refactor: replace service by containers (#32) #97

Workflow file for this run

name: rust-build
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
on:
pull_request:
paths:
- .github/workflows/rust-build.yml
- charts/simpaas-app/**
- resources/**
- src/**
- Cargo.*
- Dockerfile
push:
branches: [main]
tags: [v*]
workflow_dispatch:
inputs:
platforms:
required: false
type: string
default: linux/amd64,linux/arm64
push:
required: false
type: boolean
default: false
jobs:
cargo:
name: cargo
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: set up rust
id: rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: restore rust cache
uses: actions/cache@v4
with:
path: |
~/.cargo/
target/
key: cargo-debug-${{ steps.rust.outputs.cachekey }}-${{ hashFiles('Cargo.*') }}
- name: build
run: cargo build
docker:
name: docker
runs-on: ubuntu-latest
strategy:
matrix:
target:
- api
- op
steps:
- name: checkout
uses: actions/checkout@v4
- name: set up qemu
uses: docker/setup-qemu-action@v3
- name: set up buildx
uses: docker/setup-buildx-action@v3
- name: login to docker hub
if: startsWith(github.ref, 'refs/tags/') || inputs.push
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: get image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ vars.DOCKERHUB_USER }}/simpaas-${{ matrix.target }}
tags: |
type=sha,enable=${{ !startsWith(github.ref, 'refs/tags/') }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
flavor: |
latest=auto
- name: build
uses: docker/build-push-action@v5
with:
context: .
target: ${{ matrix.target }}
tags: ${{ steps.meta.outputs.tags }}
platforms: ${{ inputs.platforms || 'linux/amd64,linux/arm64' }}
cache-from: type=gha,mode=max
cache-to: type=gha,mode=max
push: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.push) }}