Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHORE]: development workflows. local and dev docker files #593

Merged
merged 8 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This release drafter follows the conventions
# from https://keepachangelog.com

name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
template: |
## What Changed 👀

$CHANGES

**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION

categories:
- title: 🚀 Features
labels:
- feature
- enhancement
- title: 🐛 Bug Fixes
labels:
- fix
- bug
- title: ⚠️ Changes
labels:
- changed
- title: ⛔️ Deprecated
labels:
- deprecated
- title: 🗑 Removed
labels:
- removed
- title: 🔐 Security
labels:
- security
- title: 📄 Documentation
labels:
- docs
- documentation
- title: 🧩 Dependency Updates
labels:
- deps
- dependencies
collapse-after: 5

change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- major
minor:
labels:
- minor
patch:
labels:
- patch
default: patch

exclude-labels:
- skip-changelog
68 changes: 68 additions & 0 deletions .github/workflows/build_docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build Docker Image

on:
workflow_call:
inputs:
DOCKERFILE:
required: true
type: string
REPOSITORY:
required: true
type: string
BUILD_ARGS:
required: false
type: string
default: ''

env:
REGISTRY: split.azurecr.io
TAG: ${{ github.sha }}

jobs:
build_docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Context for Buildx
run: |
docker context create builders

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
endpoint: builders

- uses: azure/docker-login@v1
with:
login-server: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Setup Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ inputs.REPOSITORY }}
tags: |
type=raw,value=${{ env.TAG }}
type=raw,value=cache

- name: Build and Push
uses: docker/build-push-action@v3
with:
context: .
file: ${{ inputs.DOCKERFILE }}
push: true
target: production
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=registry,ref=${{ env.REGISTRY }}/${{ inputs.REPOSITORY }}:${{ env.TAG }}
type=registry,ref=${{ env.REGISTRY }}/${{ inputs.REPOSITORY }}:cache
cache-to: type=inline
build-args: ${{ inputs.BUILD_ARGS }}
28 changes: 0 additions & 28 deletions .github/workflows/deploy_backend.yml

This file was deleted.

114 changes: 114 additions & 0 deletions .github/workflows/deploy_backend_frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Build and Deploy

on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
build_backend:
name: Build backend
uses: ./.github/workflows/build_docker.yaml
with:
DOCKERFILE: ./backend/docker/prod/Dockerfile
REPOSITORY: backend

build_frontend:
name: Build frontend
uses: ./.github/workflows/build_docker.yaml
with:
DOCKERFILE: ./frontend/docker/prod/Dockerfile
REPOSITORY: frontend
BUILD_ARGS: |
NEXT_PUBLIC_BACKEND_URL=${{secrets.NEXT_PUBLIC_BACKEND_URL}}
NEXT_PUBLIC_NEXTAUTH_URL=${{secrets.NEXT_PUBLIC_NEXTAUTH_URL}}
NEXT_PUBLIC_EXPIRATION_TIME=${{secrets.NEXT_PUBLIC_EXPIRATION_TIME}}
NEXT_PUBLIC_ENABLE_AZURE=${{secrets.NEXT_PUBLIC_ENABLE_AZURE}}

deploy_backend_dev:
name: Deploy backend DEV
needs: build_backend
uses: ./.github/workflows/on_call_deploy.yaml
with:
ENVIRONMENT: dev
APP_NAME: split-be-dev
PUBLISH_PROFILE: ${{ secrets.AZURE_BACKEND_PUBLISH_PROFILE }}
REPOSITORY: backend

deploy_frontend_dev:
name: Deploy frontend DEV
needs: build_frontend
uses: ./.github/workflows/on_call_deploy.yaml
with:
ENVIRONMENT: dev
APP_NAME: split-fe-dev
PUBLISH_PROFILE: ${{ secrets.AZURE_FRONTEND_PUBLISH_PROFILE }}
REPOSITORY: frontend

deploy_backend_prod:
name: Deploy backend PROD
needs: deploy_backend_dev
uses: ./.github/workflows/on_call_deploy.yaml
with:
ENVIRONMENT: prod
APP_NAME: split-be
PUBLISH_PROFILE: ${{ secrets.AZURE_BACKEND_PUBLISH_PROFILE }}
REPOSITORY: backend

deploy_frontend_prod:
name: Deploy frontend PROD
needs: deploy_frontend_dev
uses: ./.github/workflows/on_call_deploy.yaml
with:
ENVIRONMENT: prod
APP_NAME: split-fe
PUBLISH_PROFILE: ${{ secrets.AZURE_FRONTEND_PUBLISH_PROFILE }}
REPOSITORY: frontend

update_release_draft:
name: Release Drafter
runs-on: ubuntu-latest
needs:
- deploy_backend_dev
- deploy_frontend_dev
steps:
- name: Update release draft
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

pre_release:
name: Create Pre Release
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- deploy_backend_dev
- deploy_frontend_dev
steps:
- name: Update release draft
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: true

release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- deploy_backend_prod
- deploy_frontend_prod
steps:
- name: Update release draft
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
publish: true
28 changes: 0 additions & 28 deletions .github/workflows/deploy_frontend.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/on_call_deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy

on:
workflow_call:
inputs:
ENVIRONMENT:
required: true
type: string
APP_NAME:
required: true
type: string
PUBLISH_PROFILE:
required: true
type: string
REPOSITORY:
required: true
type: string

env:
TAG: ${{ github.sha }}

jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.ENVIRONMENT }}
steps:
- uses: azure/webapps-deploy@v2
with:
app-name: ${{ inputs.APP_NAME }}
publish-profile: ${{ inputs.PUBLISH_PROFILE }}
images: split.azurecr.io/${{ inputs.REPOSITORY }}:${{ env.TAG }}
28 changes: 28 additions & 0 deletions .github/workflows/on_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Update Changelog

on:
release:
types:
- published

jobs:
update:
name: Update Changelog
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
release-notes: ${{ github.event.release.body }}
latest-version: ${{ github.event.release.name }}

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: main
commit_message: 'ci: update version to ${{ github.event.release.name }} [skip ci]'
push_options: --force
Loading