Skip to content

Commit

Permalink
Merge pull request #655 from Health-Informatics-UoN/devel
Browse files Browse the repository at this point in the history
Merge dev to prod 2.0.14
  • Loading branch information
AndyRae authored Mar 20, 2024
2 parents 3627970 + c2777b0 commit eb8b2f0
Show file tree
Hide file tree
Showing 219 changed files with 12,039 additions and 1,664 deletions.
26 changes: 26 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"Area: Migrations":
- 'app/api/mapping/migrations/*'

dependencies:
- 'app/react-client-app/package.json'
- 'app/react-client-app/package-lock.json'
- 'poetry.lock'
- 'pyproject.toml'
- 'app/workers/poetry.lock'
- 'app/workers/pyproject.toml'
- 'app/api/poetry.lock'
- 'app/api/pyproject.toml'

"Area: CI":
- '.github/**/*'

"Area: Backend":
- 'app/api/**'
- 'lib/Data/**'
- 'lib/Monitor.Shared/**'

"Area: Frontend":
- 'app/react-client-app/**'

"Area: Workers":
- 'app/workers/**'
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Build the docker image
run: docker build -f Dockerfile.deploy -t ccom-build:latest .
run: docker build -f app/Dockerfile.deploy -t ccom-build:latest .
- name: Run the docker image
run: |
#startup the stack
Expand Down
189 changes: 189 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
name: Build and Deploy to Azure - ccom

on:
push:
branches:
- master
workflow_dispatch:

env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: './app/workers'
PYTHON_VERSION: '3.8'

jobs:
build-and-publish-workers:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4

- name: Setup Python ${{ env.PYTHON_VERSION }} Environment
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: 'Install Poetry'
uses: snok/install-poetry@v1

- name: 'Resolve Project Dependencies Using Poetry'
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
poetry config virtualenvs.create false
poetry export --format requirements.txt --output requirements.txt
popd
shell: bash

- name: 'Install Dependencies Using Pip'
shell: bash
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
python -m pip install --upgrade pip
pip install -r requirements.txt --target=".python_packages/lib/site-packages"
popd
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: functionsapp
path: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}

build-and-publish-web:
runs-on: 'ubuntu-latest'

steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to registry
uses: docker/login-action@v3
with:
registry: ccomreg.azurecr.io
username: ${{ secrets.REGISTRY_USERNAME_DEV }}
password: ${{ secrets.REGISTRY_PASSWORD_DEV }}

- name: Build and push container image to registry
uses: docker/build-push-action@v5
with:
push: true
tags: ccomreg.azurecr.io/${{ secrets.REGISTRY_USERNAME_DEV }}/latest:${{ github.sha }}
file: ./app/Dockerfile.deploy

# Deploy Workers Dev
deploy-workers-dev:
runs-on: ubuntu-latest
needs: [build-and-publish-workers, build-and-publish-web]
environment: dev

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
path: functionsapp
name: functionsapp

- name: 'Run Azure Functions Action'
uses: Azure/[email protected]
id: fa
with:
app-name: 'ccom-funcs-dev'
slot-name: 'production'
package: ${{ github.workspace }}/functionsapp
publish-profile: ${{ env.AZURE_FUNCAPP_PUBLISH_PROFILE }}

# Deploy Web App Dev
deploy-web-dev:
runs-on: ubuntu-latest
needs: [build-and-publish-web, deploy-workers-dev]
environment:
name: 'dev'
url: ${{ steps.deploy-web-dev.outputs.webapp-url }}

steps:
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'ccom-dev'
publish-profile: ${{ env.AZURE_WEBAPP_PUBLISH_PROFILE }}
images: 'ccomreg.azurecr.io/${{ secrets.REGISTRY_USERNAME_DEV }}/latest:${{ github.sha }}'

# Deploy Workers Test
deploy-workers-test:
runs-on: ubuntu-latest
needs: deploy-workers-dev
environment: test

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
path: functionsapp
name: functionsapp

- name: 'Run Azure Functions Action'
uses: Azure/[email protected]
id: fa
with:
app-name: 'ccom-funcs-test'
slot-name: 'production'
package: ${{ github.workspace }}/functionsapp
publish-profile: ${{ env.AZURE_FUNCAPP_PUBLISH_PROFILE }}

# Deploy Web App Test
deploy-web-test:
runs-on: ubuntu-latest
needs: [deploy-web-dev, deploy-workers-test]
environment:
name: 'test'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'ccom-test'
publish-profile: ${{ env.AZURE_WEBAPP_PUBLISH_PROFILE }}
images: 'ccomreg.azurecr.io/${{ secrets.REGISTRY_USERNAME_DEV }}/latest:${{ github.sha }}'

# Deploy Workers Production
deploy-workers-production:
runs-on: ubuntu-latest
needs: deploy-workers-test
environment: production

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
path: functionsapp
name: functionsapp

- name: 'Run Azure Functions Action'
uses: Azure/[email protected]
id: fa
with:
app-name: 'ccom-funcs-prod'
slot-name: 'production'
package: ${{ github.workspace }}/functionsapp
publish-profile: ${{ env.AZURE_FUNCAPP_PUBLISH_PROFILE }}

# Deploy Web App Production
deploy-web-production:
runs-on: ubuntu-latest
needs: [deploy-web-test, deploy-workers-production]
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'ccom'
slot-name: 'production'
publish-profile: ${{ env.AZURE_WEBAPP_PUBLISH_PROFILE }}
images: 'ccomreg.azurecr.io/${{ secrets.REGISTRY_USERNAME_DEV }}/latest:${{ github.sha }}'
34 changes: 0 additions & 34 deletions .github/workflows/devel.yml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/devel_ccom-funcs-dev.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler

name: Labeler
on: [pull_request]

jobs:
label:

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
43 changes: 0 additions & 43 deletions .github/workflows/prod_ccom-func-prod.yml

This file was deleted.

Loading

0 comments on commit eb8b2f0

Please sign in to comment.