65 lines
1.8 KiB
YAML
65 lines
1.8 KiB
YAML
name: Test and Build Docker Image
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
workflow_dispatch:
|
|
schedule:
|
|
- cron: "0 0 * * *"
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
SECRET_KEY: 1234567890
|
|
DEBUG: True
|
|
ADMIN_EMAIL: 4153203+TheLovinator1@users.noreply.github.com
|
|
EMAIL_HOST_USER: ${{ secrets.EMAIL_HOST_USER }}
|
|
EMAIL_HOST_PASSWORD: ${{ secrets.EMAIL_HOST_PASSWORD }}
|
|
DB_NAME: feedvault
|
|
DB_USER: feedvault
|
|
DB_PASSWORD: githubtest
|
|
DB_HOST: 127.0.0.1
|
|
DB_PORT: 5432
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
|
|
POSTGRES_DB: ${{ env.DB_HOST }}
|
|
POSTGRES_USER: ${{ env.DB_USER }}
|
|
ports:
|
|
- 5432:5432
|
|
options: --health-cmd pg_isready --health-interval 1s --health-timeout 5s --health-retries 5
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.12
|
|
- run: pipx install poetry
|
|
- run: poetry install
|
|
- run: poetry run python manage.py migrate
|
|
- run: poetry run python manage.py test
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
if: github.event_name != 'pull_request'
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
needs: test
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: |
|
|
ghcr.io/thelovinator1/feedvault:latest
|