-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (45 loc) · 1.33 KB
/
docker-image.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
name: Docker Image CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Generate .env file
uses: SpicyPizza/[email protected]
with:
# 3rd party variables.
envkey_POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
envkey_POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
envkey_POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
envkey_CERTBOT_EMAIL: ${{ secrets.CERTBOT_EMAIL }}
envkey_CERTBOT_DOMAIN: ${{ secrets.CERTBOT_DOMAIN }}
file_name: .env
fail_on_empty: false
- name: Build the Docker image
run: |
docker compose build
docker compose run --rm web python manage.py makemigrations
docker compose run --rm web python manage.py migrate
docker compose run --rm web python manage.py collectstatic --no-input
test:
runs-on: self-hosted
needs:
- build
steps:
- name: Run tests
run: |
docker compose run --rm web python manage.py test
deploy:
runs-on: self-hosted
needs:
- build
- test
steps:
- name: Deploy
run: |
docker compose up -d --force-recreate --remove-orphans