-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (74 loc) · 3 KB
/
api.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
name: API CI
on:
push:
branches: [ "main" ]
paths:
- 'api/**'
- .github/workflows/api.yml
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: echo ${{ secrets.REGISTRY_TOKEN }} | docker login ghcr.io -u USERNAME --password-stdin
- run: echo "ENV VERSION=$GITHUB_SHA" >> ./Dockerfile
- name: Build the Docker image
run: docker build ./api --file ./api/Dockerfile --tag ghcr.io/gessfred/keybored-api:$GITHUB_SHA
- run: docker push ghcr.io/gessfred/keybored-api:$GITHUB_SHA
- run: docker build ./api --file ./api/Dockerfile --tag ghcr.io/gessfred/keybored-api:latest
- run: docker push ghcr.io/gessfred/keybored-api:latest
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Test SQL queries
run: |
cd sql
pip install -r requirements.txt
pytest
- name: Test API
run: |
cd api
pip install -r requirements.txt
pytest
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install doctl
uses: digitalocean/[email protected]
with:
token: ${{ secrets.DIGITAL_OCEAN_TOKEN }}
version: 1.91.0
# - run: sudo snap install doctl
# - run: sudo snap connect doctl:kube-config
# - run: sudo ls /home/runner/
# - run: sudo mkdir /home/runner/.config/doctl
# - run: sudo doctl auth init -t ${{ secrets.DIGITAL_OCEAN_TOKEN }}
# - run: sudo apt-get install -y ca-certificates curl
# - run: curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
# - run: echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
# - run: sudo apt-get update -y && sudo apt-get install -y kubectl
- run: /opt/hostedtoolcache/doctl/1.91.0/x64/doctl version
- run: sudo ls /home/runner/.config/doctl/
- run: sudo mkdir /root/.kube
#- run: sudo ls -al /root/.kube
- run: sudo /opt/hostedtoolcache/doctl/1.91.0/x64/doctl kubernetes cluster kubeconfig save k8s-amiscan-1-22-7-do-0-fra1-1648193990670
- run: sed -i "s/:latest/:${GITHUB_SHA}/g" ./api/deployment.yaml
- run: sudo kubectl config get-contexts
- run: sudo kubectl config use-context do-fra1-k8s-amiscan-1-22-7-do-0-fra1-1648193990670
- run: sudo kubectl apply -f ./api/deployment.yaml
name: Shipping...
- name: Install PostgreSQL client
run: sudo apt-get -yqq install postgresql-client
- name: Create View
env:
DB_HOST: ${{ secrets.DB_HOST }}
DB_NAME: ${{ secrets.DB_NAME }}
DB_USER: ${{ secrets.DB_USER }}
PGPASSWORD: ${{ secrets.DB_PASSWORD }}
run: echo "create or replace view typing_speed_current as $(cat sql/typing_speed_current.sql)" | psql -h $DB_HOST -U $DB_USER -d keylogger -p 25060