forked from blkerby/MapRandomizer
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (101 loc) · 2.85 KB
/
ci.yml
File metadata and controls
105 lines (101 loc) · 2.85 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: CI
on:
pull_request:
push:
branches:
- main
tags:
- v*
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
RUST_TOOLCHAIN: "1.94.1"
jobs:
formatting:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt
- run: cargo fmt --check
working-directory: ./rust
clippy:
name: Clippy Lints
env:
RUSTFLAGS: "-Dwarnings"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: clippy
- run: cargo clippy --all-targets
working-directory: ./rust
tests:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- run: cargo test
working-directory: ./rust
build-docker:
name: Build Docker image
runs-on: ubuntu-latest
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
env:
DOCKER_TAG: ${{ github.ref == 'refs/heads/main' && 'latest' || github.ref_name }}
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: |
bkerby/map-rando:${{ env.DOCKER_TAG }}
bkerby/map-rando:${{ github.sha }}
cache-from: type=registry,ref=bkerby/map-rando:buildcache
cache-to: type=registry,ref=bkerby/map-rando:buildcache,mode=max
build-args: |
GIT_COMMIT_HASH=${{ github.sha }}
deploy-dev:
name: Deploy to dev site
runs-on: ubuntu-latest
needs: build-docker
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
-
name: Install kubectl
uses: azure/setup-kubectl@v3
-
name: Deploy to Kubernetes
run: |
mkdir -p $HOME/.kube
echo "${{ secrets.KUBECONFIG }}" > $HOME/.kube/config
kubectl set image deployment/maprando-web-dev \
maprando-web-dev=bkerby/map-rando:${{ github.sha }} \
-n default
kubectl rollout status deployment/maprando-web-dev -n default