Added docker workflow file #23
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker build and export | |
on: | |
push: | |
branches: | |
- "master" | |
pull_request: | |
env: | |
WEB_TEST_TAG: dbase-web:test | |
WEB_LATEST_TAG: gafderkspersonal/dbase-web:latest | |
NGINX_LATEST_TAG: gafderkspersonal/dbase-nginx:latest | |
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: Build web test image | |
uses: docker/build-push-action@v5 | |
with: | |
target: web-test | |
context: . | |
load: true | |
tags: ${{ env.WEB_TEST_TAG }} | |
- 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_TAG }} \ | |
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_TAG }} | |
- name: Build and push web image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
target: runtime | |
tags: ${{ env.WEB_LATEST_TAG }} | |
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' | |
- name: Build and push nginx image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
target: nginx | |
tags: ${{ env.NGINX_LATEST_TAG }} | |
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' |