Skip to content

👷 Split CI into check and build, add docker cache #54

👷 Split CI into check and build, add docker cache

👷 Split CI into check and build, add docker cache #54

Workflow file for this run

name: Build and Push Backend
on:
push:
paths:
- backend/**
- .github/workflows/backend.yaml
branches:
- main
workflow_dispatch:
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
SQLX_OFFLINE: "true"
defaults:
run:
working-directory: backend
jobs:
check-code:
runs-on: ubuntu-latest
steps:
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
override: true
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --manifest-path backend/Cargo.toml
- name: Run Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path backend/Cargo.toml
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push (alpine)
uses: docker/build-push-action@v3
with:
context: backend
file: backend/Dockerfile.alpine
push: true
tags: |
ghcr.io/schitcrafter/ruscalimat/backend:dev-latest-alpine
ghcr.io/schitcrafter/ruscalimat/backend:dev-${{ github.run_number }}-alpine
cache-from: type=gha
cache-to: type=gha,mode=max