添加CICD相关
build / build-rust (push) Failing after 22s Details

This commit is contained in:
soul-walker 2024-09-15 00:33:02 +08:00
parent 201bfdc1fd
commit 3a35510b57
4 changed files with 79 additions and 3 deletions

View File

@ -0,0 +1,66 @@
name: build
on:
push:
branches:
- local-test
jobs:
build-rust:
runs-on: joylink-local233
steps:
- name: 检出代码
uses: https://gitea.joylink.club/actions/checkout@v4
with:
submodules: recursive
- name: Install Rust
run: |
export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
curl --proto '=https' --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh
mkdir -p ~/.cargo
echo '[source.crates-io]' > ~/.cargo/config.toml
echo 'replace-with = "rsproxy-sparse"' >> ~/.cargo/config.toml
echo '[source.rsproxy]' >> ~/.cargo/config.toml
echo 'registry = "https://rsproxy.cn/crates.io-index"' >> ~/.cargo/config.toml
echo '[source.rsproxy-sparse]' >> ~/.cargo/config.toml
echo 'registry = "sparse+https://rsproxy.cn/index/"' >> ~/.cargo/config.toml
echo '[registries.rsproxy]' >> ~/.cargo/config.toml
echo 'index = "https://rsproxy.cn/crates.io-index"' >> ~/.cargo/config.toml
echo '[net]' >> ~/.cargo/config.toml
echo 'git-fetch-with-cli = true' >> ~/.cargo/config.toml
cat ~/.cargo/config.toml
- uses: https://gitea.joylink.club/actions/rust-cache@v2
- name: build Release
run: |
rustup target add x86_64-unknown-linux-musl
cargo build --release --target x86_64-unknown-linux-musl
- name: 设置 Docker
uses: https://gitea.joylink.club/actions/local-setup-docker-cli-action@v0.1.1
- name: 设置 Docker Buildx
uses: https://gitea.joylink.club/actions/local-setup-buildx-action@v0.1.3
- name: docker登录gitea.joylink.club
uses: https://gitea.joylink.club/docker/login-action@v3
with:
registry: gitea.joylink.club
username: shengxuqiang
password: ${{ secrets.SHENGXUQIANG_PASSWORD }}
- name: Docker Build and push
uses: https://gitea.joylink.club/docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
gitea.joylink.club/joylink/rtss-simulation:local-test
- name: 发布到本地测试环境
uses: https://gitea.joylink.club/appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.LOCAL_233_SSH_HOST }}
port: ${{ secrets.LOCAL_233_SSH_PORT }}
username: ${{ secrets.LOCAL_233_SSH_USER }}
password: ${{ secrets.LOCAL_233_SSH_PASSWORD }}
script: |
docker rm -f rtss-simulation || echo "rtss-simulation not exist"
docker pull gitea.joylink.club/joylink/rtss-simulation:local-test
docker run --name rtss-simulation --restart=always -e RUN_MODE=local-test --network net --ip 10.11.11.11 -d -p 8765:8765 -v /usr/local/joylink/logs/simulation:/logs/simulation gitea.joylink.club/joylink/rtss-simulation:local-test

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM alpine
ENV RUN_MODE=prod
WORKDIR /rtss_sim
COPY ./target/x86_64-unknown-linux-musl/release/rtss_simulation ./rtss_sim
COPY ./conf/* ./conf/
COPY ./migrations/* ./migrations/
EXPOSE 8765
CMD ["sh", "-c", "./rtss_sim db migrate && ./rtss_sim serve"]

View File

@ -1,2 +0,0 @@
[database]
url = "postgresql://joylink:Joylink@0503@192.168.33.233:5432/joylink"

View File

@ -1,5 +1,5 @@
[database]
url = "postgresql://joylink:Joylink@0503@192.168.33.233:5432/joylink"
url = "postgresql://joylink:Joylink@0503@10.11.11.2:5432/joylink"
[log]
level = "info"