-
Notifications
You must be signed in to change notification settings - Fork 7
125 lines (109 loc) · 3.32 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
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
name: Test, Build, Deploy
on:
push:
branches:
- "**"
paths:
- "tubee/**"
- "app.py"
- "celery_worker.py"
- "pyproject.toml"
- "poetry.lock"
- ".github/workflows/test.yml"
pull_request:
workflow_dispatch:
jobs:
test:
name: Test Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version-file: ".python-version"
cache: "poetry"
- name: Install Dependencies
run: |
poetry env use $(cat '.python-version')
poetry install --no-interaction --no-ansi
- name: Testing
run: poetry run flask test --coverage
- name: Report coverage
uses: codecov/codecov-action@v3
license:
name: License Scan
runs-on: ubuntu-latest
if: ${{ github.event_path == 'pyproject.toml' || github.event_path == 'poetry.lock' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version-file: ".python-version"
cache: "poetry"
- name: Export requirements.txt
run: |
poetry export --dev -f requirements.txt --output requirements.txt
# FOSSA's API Key are meant to be exposed as to doc
- name: Scan License
uses: fossa-contrib/fossa-action@v1
with:
fossa-api-key: 2d7865a44aa575d857521faaee1a57f8
build:
name: Build and Push Image
runs-on: ubuntu-latest
needs: [test, license]
if: |
always()
&& (github.ref_name == 'main')
&& (github.event_name != 'pull_request')
&& (needs.test.result == 'success')
&& (needs.license.result == 'success' || needs.license.result == 'skipped')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
tags: |
type=edge
- name: Build and Push Image
uses: tomy0000000/actions/build-push-image@main
with:
docker_password: ${{ secrets.DOCKER_PASSWORD }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
name: Deploy to Beta
runs-on: ubuntu-latest
environment: Beta
needs: build
if: ${{ always() && (needs.build.result == 'success') }}
steps:
- name: SSH and execute deployment
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
port: ${{ secrets.PORT }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script_stop: true
script: |
cd tubee-beta
docker compose down
rm docker-compose.yml
wget "https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/docker-compose.yml"
docker compose pull --quiet
docker compose up --detach
docker network connect nginx_default tubee_beta_app