diff --git a/.github/actions/build-publish-api/action.yml b/.github/actions/build-publish-api/action.yml index 65ace41b..e6f48c45 100644 --- a/.github/actions/build-publish-api/action.yml +++ b/.github/actions/build-publish-api/action.yml @@ -26,8 +26,6 @@ inputs: runs: using: composite steps: - - name: Checkout repository - uses: actions/checkout@v4 - name: Log in to the Container registry uses: docker/login-action@v3 with: diff --git a/.github/actions/deploy-backend/action.yml b/.github/actions/deploy-backend/action.yml new file mode 100644 index 00000000..e69de29b diff --git a/.github/actions/deploy-frontend/action.yml b/.github/actions/deploy-frontend/action.yml new file mode 100644 index 00000000..718d243b --- /dev/null +++ b/.github/actions/deploy-frontend/action.yml @@ -0,0 +1,28 @@ +name: Deploy ReportVisions Frontend Service +description: Deploy the frontend from a tarball to Azure Blob storage in the appropriate environment. +inputs: + deploy-env: + description: The environment being deployed (e.g. "prod" or "test") + required: true + frontend-tarball: + description: The path to the tar file containing the client code to deploy + required: true + +runs: + using: composite + steps: + - name: Unpack frontend + shell: bash + run: | + mkdir frontend-build; + tar -C frontend-deploy -zxvf ${{ inputs.frontend-tarball }} + - name: Upload frontend to the environments Azure Blob Storage + shell: bash + run: | + az storage blob upload-batch -s frontend-deploy/ -d '$web' \ + --account-name reportvisionfrontend${{ inputs.deploy_env }} \ + --overwrite + - name: Logout out of Azure + shell: bash + run: | + az logout \ No newline at end of file diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 297407ae..fcc4fef9 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -1,22 +1,24 @@ 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 - ocr-version: - description: 'Create a version for this OCR API image' - required: true + push: + branches: deploy-both-ocr-api-frontend + # workflow_dispatch: + # inputs: + # deploy-env: + # description: 'The environment to deploy to' + # required: true + # type: choice + # options: + # - dev + # - dev2 + # - dev3 + # - dev4 + # - dev5 + # - dev6 + # ocr-version: + # description: 'Create a version for this OCR API image' + # required: true permissions: contents: read @@ -26,41 +28,40 @@ permissions: env: NODE_VERSION: 20 - OCR_API_URL: 'https://reportvision-ocr-dev.azurewebsites.net/' jobs: - build-publish-ocr: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Build and Push backend - 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 }} - dockerfile-path: ./OCR/Dockerfile - docker-context-path: ./OCR/ - api-name: ocr-api + # build-publish-ocr: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - name: Build and Push backend + # 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 }} + # dockerfile-path: ./OCR/Dockerfile + # docker-context-path: ./OCR/ + # api-name: ocr-api build-frontend: runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} + environment: dev2 steps: - uses: actions/checkout@v4 - uses: ./.github/actions/build-frontend - name: Build front-end application + name: Build frontend with: - api-endpoint: ${{ env.OCR_API_URL }} + api-endpoint: https://reportvision-ocr-dev2.azurewebsites.net/ frontend-tarball: ./frontend.tgz - deploy-env: ${{ inputs.deploy-env }} + deploy-env: dev2 frontend-path: ./frontend frontend-build-path: ./frontend/dist/ environment-setup: runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} + environment: dev2 steps: - uses: actions/checkout@v4 - uses: azure/login@v2 @@ -71,9 +72,28 @@ jobs: - 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 }} + deploy-env: dev2 + azure-resource-group: reportvision-rg-dev2 azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - app-name: reportvision \ No newline at end of file + app-name: reportvision + + deploy-services: + runs-on: ubuntu-latest + environment: dev2 + needs: [build-frontend, environment-setup] + steps: + - uses: actions/checkout@v4 + with: + name: frontend-tarball + - 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: dev2 \ No newline at end of file