Files
ZeptaLab Bot ca775da1f1
CI/CD / lint-and-test (push) Has been cancelled
CI/CD / build-and-push (push) Has been cancelled
CI/CD / deploy (push) Has been cancelled
feat: initial commit - Rust + React URL shortener
2026-05-31 20:45:50 +00:00

93 lines
2.4 KiB
YAML

# Gitea Actions CI/CD Pipeline
name: CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install frontend dependencies
run: cd frontend && npm ci
- name: Build frontend
run: cd frontend && npm run build
- name: Rust fmt check
run: cargo fmt --check
- name: Rust clippy
run: cargo clippy -- -D warnings
- name: Rust tests
run: cargo test
build-and-push:
needs: lint-and-test
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Harbor
uses: docker/login-action@v3
with:
registry: harbor.k8s.crashpoint.ru
username: ${{ secrets.HARBOR_USER }}
password: ${{ secrets.HARBOR_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: harbor.k8s.crashpoint.ru/hello-web/hello-web
tags: |
type=sha
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
needs: build-and-push
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Deploy to Kubernetes
run: |
sed -i "s|IMAGE_PLACEHOLDER|harbor.k8s.crashpoint.ru/hello-web/hello-web:sha-${{ github.sha }}|g" k8s/deployment.yaml
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
kubectl apply -f k8s/ingress.yaml
kubectl rollout status deployment/hello-web --timeout=120s