-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
79 lines (71 loc) · 1.73 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
.rust-cache: &rust-cache
paths:
- .cargo/bin/
- .cargo/registry/index/
- .cargo/registry/cache/
- .cargo/git/db/
- target/
policy: pull-push
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE
IMAGE_TAG: $CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
IMAGE: $IMAGE_NAME:$IMAGE_TAG
CARGO_INCREMENTAL: 0
CARGO_HOME: $CI_PROJECT_DIR/.cargo
workflow:
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
stages:
- build
- test
- predeploy
- deploy
build-test:
image: messense/rust-musl-cross:aarch64-musl
stage: build
script:
- cargo test --no-run --locked
cache:
<<: *rust-cache
key: test
build-binary:
image: messense/rust-musl-cross:aarch64-musl
stage: build
script:
- cargo build --release
cache:
<<: *rust-cache
key: binary
artifacts:
paths:
- target/aarch64-unknown-linux-musl/release/butler-bot
test:
image: messense/rust-musl-cross:aarch64-musl
stage: test
script:
- cargo test -- --nocapture --quiet
cache:
<<: *rust-cache
key: test
policy: pull
build-and-push-docker-image:
image: docker:19.03.12
stage: predeploy
services:
- docker:19.03.12-dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $IMAGE .
- docker push $IMAGE
deploy:
image:
name: bitnami/kubectl:latest
entrypoint: [""]
stage: deploy
before_script:
- curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
script:
- kubectl config get-contexts
- kubectl config use-context erigara-group/gitlab-agent:primary-agent
- (cd ./manifests && ../kustomize edit set image IMAGE=$IMAGE)
- kubectl apply -k ./manifests