feat: add ci

This commit is contained in:
2026-04-09 16:46:00 +02:00
parent 248dc3d634
commit 4e969354a2
7 changed files with 151 additions and 18 deletions
+45
View File
@@ -0,0 +1,45 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
name: Rust CI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: Cache Cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
# - name: Run tests
# run: cargo test --workspace --verbose
- name: Run Clippy (linter)
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run fmt check
run: cargo fmt --all -- --check
- name: Build project
run: cargo build --workspace --verbose
+82
View File
@@ -0,0 +1,82 @@
name: Publish & Deploy
on:
push:
tags:
- 'v*'
permissions:
contents: write
actions: read
jobs:
build-and-push:
name: Build and Push to Registry
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare Repo Name
id: repo_name
run: |
echo "REPO_LOWER=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Login to Gitea Registry
uses: https://github.com/docker/login-action@v3
with:
registry: https://gitea.iceberg.black
username: docker-bot
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
- name: Build and Push
uses: https://github.com/docker/build-push-action@v5
with:
context: .
push: true
tags: |
gitea.iceberg.black/${{ env.REPO_LOWER }}:${{ github.ref_name }}
- name: Link package to repository
run: |
PKG_NAME=${REPO_LOWER#*/}
OWNER=${REPO_LOWER%/*}
RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" -X POST \
"https://gitea.iceberg.black/api/v1/packages/${OWNER}/container/${PKG_NAME}/-/link/${PKG_NAME}" \
-H "Authorization: token ${{ secrets.CONTAINER_REGISTRY_TOKEN }}")
echo "Link response: $RESPONSE"
deploy:
name: Deploy via SSH
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Copy docker-compose to server
run: |
scp docker-compose.yml bot@${{ secrets.SSH_HOST }}:/opt/iceberg/docker-compose.yml
- name: Execute remote deployment
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SSH_HOST }}
username: bot
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
scp docker-compose.yml bot@your-server:/opt/iceberg/docker-compose.yml
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "${{ secrets.CONTAINER_REGISTRY_TOKEN }}" | docker login gitea.iceberg.black -u "docker-bot" --password-stdin
docker pull gitea.iceberg.black/${{ env.REPO_LOWER }}:${{ github.ref_name }}
docker logout gitea.iceberg.black
docker stop chat || true
docker rm chat || true
docker compose up -d
docker image prune -af