Files
ItzYumeii cdd481107e
CI/CD / Build (push) Successful in 2m12s
CI/CD / Frontend Build (push) Successful in 1m9s
CI/CD / Unit Tests (push) Successful in 3m22s
CI/CD / Frontend Docker (push) Successful in 6m41s
CI/CD / Docker (push) Successful in 10m43s
feat(DRW-001) more fixes to ci
2026-09-13 21:11:29 +03:00

193 lines
5.2 KiB
YAML

name: CI/CD
on:
push:
branches:
- '**'
workflow_dispatch:
env:
REGISTRY: gitea.kawaii-alyssa.dev
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Cache Rust build
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: rust-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: rust-${{ runner.os }}-
- name: Build
run: cargo build --release --locked
- name: Run clippy
run: cargo clippy --release --all-targets --locked -- -D warnings
test:
name: Unit Tests
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Cache Rust build
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: rust-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: rust-${{ runner.os }}-
- name: Run tests
run: cargo test --release --locked
docker:
name: Docker
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Compute image metadata
id: meta
run: |
IMAGE="${{ env.REGISTRY }}/${{ gitea.repository }}"
IMAGE=$(echo "$IMAGE" | tr '[:upper:]' '[:lower:]')
SHORT_SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
if [[ "${{ gitea.ref }}" == refs/heads/release/* ]]; then
VERSION=$(echo "${{ gitea.ref_name }}" | sed 's|release/||')
TAG="${VERSION}"
TAGS="${IMAGE}:${TAG}
${IMAGE}:latest"
else
BRANCH=$(echo "${{ gitea.ref_name }}" | tr '/' '-')
TAG="${BRANCH}-${SHORT_SHA}"
TAGS="${IMAGE}:${TAG}"
fi
echo "image=${IMAGE}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "Image: ${IMAGE}:${TAG}"
- name: Log in to Gitea container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ gitea.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Set up Docker Build
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
frontend-build:
name: Frontend Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
working-directory: frontend
run: npm ci
- name: Type-check and build
working-directory: frontend
run: npm run build
frontend-docker:
name: Frontend Docker
needs: frontend-build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Compute image metadata
id: meta
run: |
IMAGE="${{ env.REGISTRY }}/${{ gitea.repository }}-frontend"
IMAGE=$(echo "$IMAGE" | tr '[:upper:]' '[:lower:]')
SHORT_SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
if [[ "${{ gitea.ref }}" == refs/heads/release/* ]]; then
VERSION=$(echo "${{ gitea.ref_name }}" | sed 's|release/||')
TAG="${VERSION}"
TAGS="${IMAGE}:${TAG}
${IMAGE}:latest"
else
BRANCH=$(echo "${{ gitea.ref_name }}" | tr '/' '-')
TAG="${BRANCH}-${SHORT_SHA}"
TAGS="${IMAGE}:${TAG}"
fi
echo "image=${IMAGE}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "Image: ${IMAGE}:${TAG}"
- name: Log in to Gitea container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ gitea.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Set up Docker Build
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./frontend
push: true
tags: ${{ steps.meta.outputs.tags }}
#================================================================
# Deploy is intentionally omitted for now -- this workflow only
# builds, tests, and pushes the images.
#================================================================