-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (101 loc) · 3.13 KB
/
main.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
name: Main
on: push
# branches: [ master, deploy, github-actions ]
env:
PYTHON_VERSION: 3.10.5
jobs:
requirements_txt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: pip install poetry
- name: Export requirements
run: poetry export -o requirements.txt
- name: Export dev requirements (for tests)
run: poetry export --dev -o requirements.dev.txt
- name: Store requirements.txt file
uses: actions/upload-artifact@v3
with:
name: requirements.txt
path: requirements.txt
- name: Store requirements.dev.txt file
uses: actions/upload-artifact@v3
with:
name: requirements.dev.txt
path: requirements.dev.txt
tests:
runs-on: ubuntu-latest
needs: [requirements_txt]
env:
POSTGRES_USER: trip_planner
POSTGRES_PASSWORD: trip_planner
POSTGRES_DB: trip_planner
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: requirements.dev.txt
- uses: actions/setup-python@v3
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: pip install -r requirements.dev.txt
- name: Tests
run: python -m pytest
env:
TESTDB: ${{ format('postgresql://{0}:{1}@localhost/{2}', env.POSTGRES_USER, env.POSTGRES_PASSWORD, env.POSTGRES_DB) }}
services:
postgres:
image: postgres:10
env:
POSTGRES_USER: ${{ env.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ env.POSTGRES_DB }}
ports:
- 5432:5432
assets:
runs-on: ubuntu-latest
env:
NODE_ENV: production
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16.19.0
uses: actions/setup-node@v3
with:
node-version: 16.19.0
cache: yarn
- run: yarn install --immutable --check-cache
- run: yarn rollup
- name: Store compiled assets
uses: actions/upload-artifact@v3
with:
name: assets
path: trip_planner/static/assets
docker:
runs-on: ubuntu-latest
needs: [requirements_txt, assets, tests]
if: github.ref_type == 'tag' || github.ref_name == 'main' || github.ref_name == 'master' || github.ref_name == 'deploy' || github.ref_name == 'github-actions'
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: actions/download-artifact@v3
with:
name: assets
path: trip_planner/static/assets
- uses: actions/download-artifact@v3
with:
name: requirements.txt
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_LOGIN }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ format('{0}/trip_planner:{1}', secrets.DOCKERHUB_LOGIN, github.ref_name) }}