1+ name : DevSecOps CLI CI/CD
2+
3+ on : [ push, pull_request ]
4+
5+ env :
6+ DOCKERHUB_REPO : monokkay/devsecops-cli
7+ CARGO_TERM_COLOR : always
8+
9+ jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - uses : actions/checkout@v4
14+
15+ - name : Setup Rust
16+ uses : actions-rs/toolchain@v1
17+ with :
18+ profile : minimal
19+ toolchain : stable
20+ components : rustfmt, clippy
21+ override : true
22+
23+ - name : Cache dependencies
24+ uses : actions/cache@v3
25+ with :
26+ path : |
27+ ~/.cargo/registry
28+ ~/.cargo/git
29+ target
30+ key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
31+
32+ - name : Run tests
33+ run : cargo test --all-features --workspace -- --nocapture
34+
35+ - name : Security audit
36+ run : cargo audit --deny warnings
37+
38+ - name : Format check
39+ run : cargo fmt --all -- --check
40+
41+ - name : Clippy check
42+ run : cargo clippy --all-targets --all-features -- -D warnings
43+
44+ release :
45+ needs : test
46+ runs-on : ubuntu-latest
47+ if : startsWith(github.ref, 'refs/tags/v')
48+
49+ steps :
50+ - uses : actions/checkout@v4
51+
52+ - name : Login to DockerHub
53+ uses : docker/login-action@v2
54+ with :
55+ username : ${{ secrets.DOCKERHUB_USERNAME }}
56+ password : ${{ secrets.DOCKERHUB_TOKEN }}
57+
58+ - name : Setup Docker Buildx
59+ uses : docker/setup-buildx-action@v2
60+
61+ - name : Build and push Docker image
62+ uses : docker/build-push-action@v4
63+ with :
64+ context : .
65+ platforms : linux/amd64,linux/arm64
66+ push : true
67+ tags : |
68+ ${{ env.DOCKERHUB_REPO }}:latest
69+ ${{ env.DOCKERHUB_REPO }}:${{ github.ref_name }}
70+ build-args : |
71+ RUST_VERSION=1.70.0
72+
73+ - name : Create GitHub release
74+ uses : softprops/action-gh-release@v1
75+ with :
76+ name : ${{ github.ref_name }}
77+ body : ${{ github.event.release.body }}
78+ draft : false
79+ prerelease : false
80+ files : |
81+ target/release/monokkai
82+ target/release/monokkai-http
0 commit comments