Skip to content

Commit

Permalink
try with full workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Administrator committed Oct 29, 2024
1 parent 2c46265 commit 077ec3e
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 95 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/build-deploy-ocr.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
name: Create, publish, deploy a OCR API image

on:
push:
branches: fix-docker-image-check
# workflow_dispatch:
# inputs:
# tag:
# description: 'Version tag for new release'
# required: true
workflow_dispatch:
inputs:
tag:
description: 'Version tag for new release'
required: true

env:
REGISTRY: ghcr.io
VERSION: demo-test-env-derek1
VERSION: ${{ inputs.tag }}


jobs:
Expand All @@ -23,7 +21,7 @@ jobs:
attestations: write
id-token: write
outputs:
tf_env: ${{ steps.set-environment.outputs.tf_env }}
docker_inspect: ${{ steps.image_check.outputs.docker_inspect }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -38,13 +36,13 @@ jobs:
- name: Check if image exists
id: image_check
run: |
echo "tf_env=$(
echo "docker_inspect=$(
docker manifest inspect ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:${{ env.VERSION }} > /dev/null ; echo $?
)" >> $GITHUB_OUTPUT
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
if: ${{ steps.image_check.outputs.tf_env == 1 }}
if: ${{ steps.image_check.outputs.docker_inspect == 1 }}
with:
context: ./OCR/
file: ./OCR/Dockerfile
Expand Down
181 changes: 97 additions & 84 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
name: Build and deploy all of ReportVision's services to a development environment

on:
workflow_dispatch:
inputs:
deploy-env:
description: 'The environment to deploy to'
required: true
type: choice
options:
- dev
- dev2
- dev3
- dev4
- dev5
- dev6
- demo
ocr-version:
description: 'Create a version for this OCR API image'
required: true
push:
branches: fix-docker-image-check
# workflow_dispatch:
# inputs:
# deploy-env:
# description: 'The environment to deploy to'
# required: true
# type: choice
# options:
# - dev
# - dev2
# - dev3
# - dev4
# - dev5
# - dev6
# - demo
# ocr-version:
# description: 'Create a version for this OCR API image'
# required: true

permissions:
contents: read
Expand All @@ -28,85 +30,96 @@ permissions:
jobs:
build-publish-ocr:
runs-on: ubuntu-latest
outputs:
docker_inspect: ${{ steps.image_check.outputs.docker_inspect }}
steps:
- uses: actions/checkout@v4
- name: Lowercase the repo name
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
- name: Check if image exists
id: image_check
run: |
echo "docker_inspect=$(
docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:demo-test-env-derek > /dev/null ; echo $?
)" >> $GITHUB_OUTPUT
- name: Build and Push backend
if: ${{ steps.image_check.outputs.docker_inspect == 1 }}
uses: ./.github/actions/build-publish-api
with:
docker-registry: ghcr.io
docker-pw: ${{ secrets.GITHUB_TOKEN }}
docker-username: ${{ github.actor }}
docker-tag: ${{ inputs.ocr-version }}
docker-tag: demo-test-env-derek
dockerfile-path: ./OCR/Dockerfile
docker-context-path: ./OCR/
api-name: ocr-api

build-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-frontend
name: Build frontend
with:
api-endpoint: https://reportvision-ocr-${{ inputs.deploy-env }}.azurewebsites.net/
frontend-tarball: ./frontend.tgz
frontend-path: ./frontend
frontend-build-path: ./frontend/dist/
node-version: 20
# build-frontend:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: ./.github/actions/build-frontend
# name: Build frontend
# with:
# api-endpoint: https://reportvision-ocr-${{ inputs.deploy-env }}.azurewebsites.net/
# frontend-tarball: ./frontend.tgz
# frontend-path: ./frontend
# frontend-build-path: ./frontend/dist/
# node-version: 20

environment-setup:
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env }}
steps:
- uses: actions/checkout@v4
- uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- uses: ./.github/actions/tf-setup
name: Setup this environment with Terraform
with:
deploy-env: ${{ inputs.deploy-env }}
azure-resource-group: reportvision-rg-${{ inputs.deploy-env }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
app-name: reportvision
# environment-setup:
# runs-on: ubuntu-latest
# environment: ${{ inputs.deploy-env }}
# steps:
# - uses: actions/checkout@v4
# - uses: azure/login@v2
# with:
# client-id: ${{ secrets.AZURE_CLIENT_ID }}
# tenant-id: ${{ secrets.AZURE_TENANT_ID }}
# subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# - uses: ./.github/actions/tf-setup
# name: Setup this environment with Terraform
# with:
# deploy-env: ${{ inputs.deploy-env }}
# azure-resource-group: reportvision-rg-${{ inputs.deploy-env }}
# azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
# azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
# azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# app-name: reportvision

deploy-backend:
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env }}
needs: [build-publish-ocr, environment-setup]
steps:
- uses: actions/checkout@v4
- uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Deploy OCR-API
uses: ./.github/actions/deploy-api
with:
deploy-env: ${{ inputs.deploy-env }}
docker-tag: ${{ inputs.ocr-version }}
docker-registry: ghcr.io
api-name: ocr-api
# deploy-ocr-api:
# runs-on: ubuntu-latest
# environment: ${{ inputs.deploy-env }}
# needs: [build-publish-ocr, environment-setup]
# steps:
# - uses: actions/checkout@v4
# - uses: azure/login@v2
# with:
# client-id: ${{ secrets.AZURE_CLIENT_ID }}
# tenant-id: ${{ secrets.AZURE_TENANT_ID }}
# subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# - name: Deploy OCR-API
# uses: ./.github/actions/deploy-api
# with:
# deploy-env: ${{ inputs.deploy-env }}
# docker-tag: ${{ inputs.ocr-version }}
# docker-registry: ghcr.io
# api-name: ocr-api

deploy-frontend:
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env }}
needs: [build-frontend, environment-setup]
if: ${{ inputs.deploy-env != 'demo'}}
steps:
- uses: actions/checkout@v4
- uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Deploy frontend
uses: ./.github/actions/deploy-frontend
with:
frontend-tarball: frontend.tgz
deploy-env: ${{ inputs.deploy-env }}
# deploy-frontend:
# runs-on: ubuntu-latest
# environment: ${{ inputs.deploy-env }}
# needs: [build-frontend, environment-setup]
# if: ${{ inputs.deploy-env != 'demo'}}
# steps:
# - uses: actions/checkout@v4
# - uses: azure/login@v2
# with:
# client-id: ${{ secrets.AZURE_CLIENT_ID }}
# tenant-id: ${{ secrets.AZURE_TENANT_ID }}
# subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# - name: Deploy frontend
# uses: ./.github/actions/deploy-frontend
# with:
# frontend-tarball: frontend.tgz
# deploy-env: ${{ inputs.deploy-env }}

0 comments on commit 077ec3e

Please sign in to comment.