-
Notifications
You must be signed in to change notification settings - Fork 6
45 lines (42 loc) · 1.65 KB
/
ci.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
name: Main
on:
[push, pull_request]
env:
DJANGO_SETTINGS_MODULE: hsf.test_settings
COMPOSE_INTERACTIVE_NO_CLI: 1
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build dev containers
run: |
docker buildx create --use --driver=docker-container
docker buildx bake -f ./docker-compose.yml --set *.cache-to="type=gha,mode=max" --set *.cache-from="type=gha" --load
- name: Start containers
run: docker compose up -d
- name: Run tests
run: |
docker compose exec -T web poetry run flake8 ./main
docker compose exec -T web poetry run ./manage.py test
- name: Stop containers
if: always()
run: docker compose down
- name: Login to container registry
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push production container
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/Dockerfile.prod
push: true
tags: ghcr.io/ukhackspacefoundation/website:latest
cache-to: type=gha,mode=max
cache-from: type=gha