-
Notifications
You must be signed in to change notification settings - Fork 1
75 lines (72 loc) · 2.35 KB
/
docker.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
name: Docker build and export
on:
push:
branches:
- "theme/ocd"
pull_request:
branches:
- "theme/ocd"
env:
WEB_TEST_IMAGE: dbase-web:test
WEB_IMAGE: gafderkspersonal/dbase-web
NGINX_TEST_IMAGE: dbase-nginx:test
NGINX_IMAGE: gafderkspersonal/dbase-nginx
jobs:
build:
environment: CI
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set short git commit SHA
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Output git commit SHA
run: echo ${{ steps.vars.outputs.sha_short }}
- name: Build web test image
uses: docker/build-push-action@v5
with:
target: web-test
context: .
load: true
tags: ${{ env.WEB_TEST_IMAGE }}
- name: Test web test image
run: |
docker run \
-e SECRET_KEY="${{ secrets.SECRET_KEY }}" \
-e DATABASE_URL="sqlite:////app/db.sqlite3" \
-e DEBUG=on \
--rm ${{ env.WEB_TEST_IMAGE }} \
python manage.py test --exclude-tag=functional -v 2
- name: Build nginx image
uses: docker/build-push-action@v5
with:
target: nginx
context: .
load: true
tags: ${{ env.NGINX_TEST_IMAGE }}
- name: Publish web image
uses: docker/build-push-action@v5
with:
context: .
push: true
target: runtime
tags: ${{ env.WEB_IMAGE }}:latest-ocd,${{ env.WEB_IMAGE }}:${{ steps.vars.outputs.sha_short }}-ocd
if: github.ref == 'refs/heads/theme/ocd' && github.event_name != 'pull_request'
- name: Publish nginx image
uses: docker/build-push-action@v5
with:
context: .
push: true
target: nginx
tags: ${{ env.NGINX_IMAGE }}:latest-ocd,${{ env.NGINX_IMAGE }}:${{ steps.vars.outputs.sha_short }}-ocd
if: github.ref == 'refs/heads/theme/ocd' && github.event_name != 'pull_request'