Add health check service with HTTP port configuration and update dependencies #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Production CI/CD | |
on: | |
push: | |
branches: [ master ] | |
tags: [ 'v*.*.*' ] # Semantic version pattern | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: # Manual trigger | |
inputs: | |
environment: | |
description: 'Deployment Environment' | |
required: true | |
default: 'staging' | |
type: choice | |
options: [ staging, production ] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
CARGO_TERM_COLOR: always | |
jobs: | |
fmt: | |
name: Rustfmt | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install the Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
components: rustfmt | |
- name: Enforce formatting | |
run: cargo fmt --check | |
clippy: | |
name: Clippy | |
runs-on: ubuntu-latest | |
env: | |
SQLX_OFFLINE: true | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install the Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
components: clippy | |
- name: Install protocol buffer compiler | |
run: sudo apt-get install protobuf-compiler | |
- name: Linting | |
run: cargo clippy -- -D warnings | |
test: | |
name: Test | |
needs: [ fmt, clippy ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install the Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Install protocol buffer compiler | |
run: sudo apt-get install protobuf-compiler | |
- name: Run tests | |
run: cargo test | |
docker-build: | |
name: Build Docker Image | |
runs-on: ubuntu-latest | |
needs: [ test ] | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=schedule | |
type=ref,event=branch | |
type=ref,event=tag | |
type=semver,pattern={{version}} | |
- name: Cache Docker layers | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx | |
restore-keys: | | |
${{ runner.os }}-buildx | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
provenance: true | |
sbom: true | |
push: ${{ github.ref == 'refs/heads/main' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | |
- name: Update Cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |