chore: maintainable template building with django-cotton and django-t… #3
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 Push | |
on: | |
push: | |
branches: [ "master" ] | |
tags: | |
- 'v*' | |
pull_request: | |
branches: [ "master" ] | |
env: | |
REGISTRY: ghcr.io | |
DJANGO_IMAGE_NAME: ${{ github.repository }}/django | |
POSTGRES_IMAGE_NAME: ${{ github.repository }}/postgres | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Log in to the Container registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Django | |
id: meta-django | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.DJANGO_IMAGE_NAME }} | |
- name: Build and push Django image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./compose/production/django/Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-django.outputs.tags }} | |
labels: ${{ steps.meta-django.outputs.labels }} | |
- name: Extract metadata (tags, labels) for PostgreSQL | |
id: meta-postgres | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.POSTGRES_IMAGE_NAME }} | |
- name: Build and push PostgreSQL image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./compose/production/postgres/Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-postgres.outputs.tags }} | |
labels: ${{ steps.meta-postgres.outputs.labels }} |