feat: add ci
This commit is contained in:
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo "Running rustfmt check..."
|
|
||||||
cargo fmt --all --
|
|
||||||
|
|
||||||
echo "Running Clippy..."
|
|
||||||
cargo clippy --all-targets --all-features -- -D warnings
|
|
||||||
|
|
||||||
echo "All checks passed!"
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
target
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
node_modules
|
||||||
|
.cargo-husky
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
repos:
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: fmt
|
||||||
|
name: rustfmt
|
||||||
|
language: system
|
||||||
|
entry: cargo fmt --
|
||||||
|
types: [rust]
|
||||||
|
pass_filenames: false
|
||||||
|
|
||||||
|
- id: clippy
|
||||||
|
name: clippy
|
||||||
|
language: system
|
||||||
|
entry: cargo clippy -- -D warnings
|
||||||
|
types: [rust]
|
||||||
|
pass_filenames: false
|
||||||
Generated
-7
@@ -113,12 +113,6 @@ version = "1.11.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
|
checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cargo-husky"
|
|
||||||
version = "1.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7b02b629252fe8ef6460461409564e2c21d0c8e77e0944f3d189ff06c4e932ad"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.59"
|
version = "1.2.59"
|
||||||
@@ -154,7 +148,6 @@ name = "chat"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"cargo-husky",
|
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
"jsonwebtoken",
|
"jsonwebtoken",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ version = "0.1.0"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
cargo-husky = "1.5.0"
|
lefthook = "1.0.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
axum = "0.8.8"
|
axum = "0.8.8"
|
||||||
|
|||||||
Reference in New Issue
Block a user