-
Notifications
You must be signed in to change notification settings - Fork 1
38 lines (34 loc) · 1.29 KB
/
test.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
name: Build, deploy, test
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build and test
timeout-minutes: 10
run: |
echo ${{ github.sha }} > commit.txt
docker build -t ai-ml-web:latest -f ./Dockerfile-web .
docker swarm init
docker stack deploy ai-ml -c docker-compose.yml --prune
sleep 15
until [ $(docker inspect -f "{{json .State.Status }}" $(docker ps -a --filter ancestor=ai-ml-web --format="{{.ID}}" | head -n 1)) == '"running"' ]; do echo "Waiting for container to start..." && sleep 1; done
docker container exec -i $(docker ps -f name=ai-ml_web --format "{{.ID}}") pytest web
docker container exec -i $(docker ps -f name=ai-ml_web --format "{{.ID}}") ruff check web/
- uses: superfly/flyctl-actions/setup-flyctl@master
if: ${{ github.ref == 'refs/heads/main' }}
- name: Deploy to fly.io
timeout-minutes: 10
if: ${{ github.ref == 'refs/heads/main' }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_ACCESS_TOKEN }}
run: flyctl deploy --local-only --wait-timeout=600 -i ai-ml-web:latest