Skip to content

Merge branch 'develop' of github.com:forza-mor-rotterdam/mbc into dja… #89

Merge branch 'develop' of github.com:forza-mor-rotterdam/mbc into dja…

Merge branch 'develop' of github.com:forza-mor-rotterdam/mbc into dja… #89

Workflow file for this run

name: "CI/CD Workflow"
on:
push:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
django-lint:
name: Django linting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3.1.2
with:
python-version: 3.10.10
- name: Linting
run: bash bin/cleanup_pre_commit.sh
create-docker-test-image-and-test:
name: Create Docker test image and test
runs-on: ubuntu-latest
needs: django-lint
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build Docker test image
run: docker compose -f docker-compose.test.yaml build
- name: Create Docker network
run: docker network create mbc_network
- name: Start Docker Containers
run: docker compose -f docker-compose.test.yaml up -d
- name: Run Tests
run: docker compose -f docker-compose.test.yaml run app python manage.py test
build-and-push-docker-image:
name: Build and push Docker image
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
needs: create-docker-test-image-and-test
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Get current date
id: get_date
run: echo "::set-output name=DATE::$(date +'%d-%m-%Y-%H-%M-%S')"
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta_app
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-app
tags: |
type=raw,develop
type=raw,test
- name: Extract metadata (tags, labels) for Docker nginx
id: meta_nginx
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-nginx
tags: |
type=raw,develop
type=raw,test
- name: Build and push app Docker image
uses: docker/build-push-action@v3
with:
context: "{{defaultContext}}:app"
push: true
tags: ${{ steps.meta_app.outputs.tags }}
labels: ${{ steps.meta_app.outputs.labels }}
build-args: |
GIT_SHA=${{ github.sha }}
DEPLOY_DATE=${{ steps.get_date.outputs.DATE }}
- name: Build and push nginx Docker image
uses: docker/build-push-action@v3
with:
context: "{{defaultContext}}:nginx"
push: true
tags: ${{ steps.meta_nginx.outputs.tags }}
labels: ${{ steps.meta_nginx.outputs.labels }}
deploy-acc:
name: Acceptance release
if: github.ref == 'refs/heads/develop'
needs: build-and-push-docker-image
runs-on: ubuntu-latest
environment: acc
permissions:
contents: read
packages: write
steps:
- name: Start rollout on k8s platform
uses: actions-hub/kubectl@master
env:
KUBE_HOST: ${{ vars.KUBE_HOST }}
KUBE_CERTIFICATE: ${{ vars.KUBE_CERTIFICATE }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
with:
args: rollout restart deployment/app --namespace=${{ vars.KUBE_NAMESPACE }}
- name: Status rollout on k8s platform
uses: actions-hub/kubectl@master
env:
KUBE_HOST: ${{ vars.KUBE_HOST }}
KUBE_CERTIFICATE: ${{ vars.KUBE_CERTIFICATE }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
with:
args: rollout status deployment/app --namespace=${{ vars.KUBE_NAMESPACE }}
deploy-test:
name: Test release
if: github.ref == 'refs/heads/develop'
needs: build-and-push-docker-image
runs-on: ubuntu-latest
environment: test
permissions:
contents: read
packages: write
steps:
- name: Start rollout on k8s platform
uses: actions-hub/kubectl@master
env:
KUBE_HOST: ${{ vars.KUBE_HOST }}
KUBE_CERTIFICATE: ${{ vars.KUBE_CERTIFICATE }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
with:
args: rollout restart deployment/app --namespace=${{ vars.KUBE_NAMESPACE }}
- name: Status rollout on k8s platform
uses: actions-hub/kubectl@master
env:
KUBE_HOST: ${{ vars.KUBE_HOST }}
KUBE_CERTIFICATE: ${{ vars.KUBE_CERTIFICATE }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
with:
args: rollout status deployment/app --namespace=${{ vars.KUBE_NAMESPACE }}