53 lines
1.6 KiB
YAML
53 lines
1.6 KiB
YAML
on: [push, pull_request]
|
|
|
|
name: Continuous integration
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://gitea.com/actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
uses: https://git.airpig.cn/actions/setup-rust-toolchain@v1
|
|
|
|
- name: Cache cargo registry and build
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/bin/
|
|
~/.cargo/registry/index/
|
|
~/.cargo/registry/cache/
|
|
~/.cargo/git/db/
|
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-registry-
|
|
|
|
- name: Build for musl
|
|
run: |
|
|
apt update && apt install -y musl-tools
|
|
rustup target add x86_64-unknown-linux-musl
|
|
cargo build -r --target x86_64-unknown-linux-musl
|
|
|
|
- name: Login to hub.airpig.cn
|
|
uses: https://gitea.com/docker/login-action@v3
|
|
with:
|
|
registry: hub.airpig.cn
|
|
username: admin
|
|
password: Chenweijia113!
|
|
|
|
- name: Build Docker image and push
|
|
run: |
|
|
ls
|
|
repo="sched_task"
|
|
version=$(grep -E '^version' "Cargo.toml" | awk -F'"' '{print $2}')
|
|
new_version="v${version}"
|
|
docker build -t hub.airpig.cn/library/$repo:$new_version .
|
|
docker push hub.airpig.cn/library/$repo:$new_version
|
|
docker rmi hub.airpig.cn/library/$repo:$new_version
|
|
|
|
- name: Check job status
|
|
run: |
|
|
echo "This job's status is ${{ job.status }}." |