Skip to content

git worflows github actions fix #1

git worflows github actions fix

git worflows github actions fix #1

Workflow file for this run

name: Django CI & Postgres Test
# on:
# workflow_call:
# workflow_dispatch:
on:
push:
branches: ['master', 'main']
pull_request:
branches: [ "master", 'main' ]
jobs:
django_test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: .
env:
DJANGO_SECRET_KEY: 54g6s%qjfnhbpw0zeoei=$!her*y(p%!&84rs$4l85io
POSTGRES_DB: DB1
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
DB_IGNORE_SSL: "true"
services:
postgres_main:
image: postgres:13
env:
POSTGRES_DB: ${{ env.POSTGRES_DB }}
POSTGRES_USER: ${{ env.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
max-parallel: 4
matrix:
python-version: [3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
run: |
python --version
# setup Docker buld action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.G_TOKEN }}
- name: Build image and push to Docker Hub and GitHub Container Registry
uses: docker/build-push-action@v2
with:
# relative path to the place where source code with Dockerfile is located
context: ./
# Note: tags has to be all lower-case
tags: |
joelwembo/cloudapp-django-web:${{ github.sha }}
ghcr.io/joelwembo/cloudapp-django-web:${{ github.sha }}
# build on feature branches, push only on main branch
push: ${{ github.ref == 'refs/heads/master' }}