78 lines
2.0 KiB
YAML
78 lines
2.0 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ '**' ] # alle Branches
|
|
pull_request:
|
|
branches: [ master ]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
check:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
- run: cargo check --all-features
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
- run: cargo test --all-features
|
|
|
|
clippy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: clippy
|
|
- run: cargo clippy --all-features -- -D warnings
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: [ check, test, clippy ]
|
|
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install cross-compilation tools
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y gcc-aarch64-linux-gnu
|
|
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: aarch64-unknown-linux-gnu
|
|
|
|
- name: Build ARM64
|
|
run: |
|
|
cargo build --release --target aarch64-unknown-linux-gnu
|
|
env:
|
|
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
|
|
|
|
- name: Setup SSH
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.PI_SSH_KEY }}" > ~/.ssh/deploy_key
|
|
chmod 600 ~/.ssh/deploy_key
|
|
ssh-keyscan -p 10022 localhost >> ~/.ssh/known_hosts
|
|
|
|
- name: Copy binary to Pi
|
|
run: |
|
|
scp -i ~/.ssh/deploy_key -P 10022 \
|
|
target/aarch64-unknown-linux-gnu/release/nazarick \
|
|
deploy@localhost:/opt/nazarick/nazarick.new
|
|
|
|
- name: Restart on Pi
|
|
run: |
|
|
ssh -i ~/.ssh/deploy_key -p 10022 deploy@localhost '
|
|
mv /opt/nazarick/nazarick.new /opt/nazarick/nazarick
|
|
cd /opt/nazarick
|
|
docker compose down || true
|
|
docker compose up -d
|
|
' |