126 lines (123 loc) · 4.39 KB
/
server.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: server CD
on:
push:
workflow_dispatch:
jobs:
# JOB to run change detection
changes:
runs-on: ubuntu-latest
# Set job outputs to values from filter step
outputs:
data: ${{ steps.filter.outputs.data_server }}
server: ${{ steps.filter.outputs.data_server }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
# the server is required in data, since apparently it is impossibly to schedule a job after another in GitHub
filters: |
data_server:
- '.github/**'
- 'data/**'
- 'server/**'
data-build:
needs:
- changes
if: ${{ needs.changes.outputs.data == 'true' }}
uses: ./.github/workflows/docker-build.yml
with:
image_suffix: data
context: ./data
dockerfile: Dockerfile
permissions:
contents: read
packages: write
data-deployment:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- data-build
steps:
- run: curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 && chmod +x /usr/local/bin/argocd
- run: argocd app actions run navigatum-prod restart --kind Deployment --resource-name data --auth-token ${{ secrets.ARGOCD_TOKEN }} --server ${{ secrets.ARGOCD_SERVER }}
- run: sleep 5
data-staging-deployment:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- data-build
steps:
- run: curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 && chmod +x /usr/local/bin/argocd
- run: argocd app actions run pr-${{github.event.number}} restart --kind Deployment --resource-name data --auth-token ${{ secrets.ARGOCD_TOKEN }} --server ${{ secrets.ARGOCD_SERVER }}
- run: sleep 5
server-build:
uses: ./.github/workflows/docker-build.yml
needs:
- data-deployment
- changes
if: ${{ needs.changes.outputs.server == 'true' }}
with:
image_suffix: server
context: ./server
dockerfile: Dockerfile.server
permissions:
contents: read
packages: write
mieli-search-build:
uses: ./.github/workflows/docker-build.yml
needs:
- data-deployment
- changes
if: ${{ needs.changes.outputs.server == 'true' }}
with:
image_suffix: mieli-search
context: ./server
dockerfile: Dockerfile.mielesearch
permissions:
contents: read
packages: write
api-tests:
runs-on: ubuntu-20.04
services:
mieli:
image: ghcr.io/tum-dev/navigatum-mieli-search:main
# TODO get the tags from ${{ needs.mieli-search-build.outputs.tags }}
ports:
- 7700
steps:
- uses: actions/checkout@v3.0.0
- uses: ATiltedTree/setup-rust@v1.0.5
with:
rust-version: 1.65
# run project's dependencies
- run: cargo build
working-directory: server
- run: cargo run &
working-directory: server
# Runs Schemathesis tests with all checks enabled
- uses: schemathesis/action@v1
with:
token: ${{ secrets.SCHEMATHESIS_TOKEN }}
api-name: navigatum
schema: "./openapi.yaml"
base-url: "http://localhost:8080"
args: "--endpoint='/api/[^f].*'" # disable the feedbacks endpoint
server-deployment:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- server-build
- mieli-search-build
steps:
- run: curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 && chmod +x /usr/local/bin/argocd
- run: argocd app actions run navigatum-prod restart --kind Deployment --resource-name server --auth-token ${{ secrets.ARGOCD_TOKEN }} --server ${{ secrets.ARGOCD_SERVER }}
server-staging-deployment:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- server-build
- mieli-search-build
steps:
- run: curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 && chmod +x /usr/local/bin/argocd
- run: argocd app actions run pr-${{github.event.number}} restart --kind Deployment --resource-name server --auth-token ${{ secrets.ARGOCD_TOKEN }} --server ${{ secrets.ARGOCD_SERVER }}