3.2.2 #34
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to Production | |
| on: | |
| release: | |
| types: [released] | |
| env: | |
| AZURE_FUNCTIONAPP_PACKAGE_PATH: "./app/workers" | |
| AZURE_WEBAPP_PACKAGE_PATH: "./app/next-client-app" | |
| PYTHON_VERSION: "3.11" | |
| NODE_VERSION: 20 | |
| app-name: carrot | |
| repo-owner: health-informatics-uon | |
| registry: ghcr.io | |
| permissions: | |
| contents: read # Required to read the repository contents | |
| packages: write # Required to publish packages | |
| jobs: | |
| build-and-publish-workers: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "Checkout GitHub Action" | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Setup Python ${{ env.PYTHON_VERSION }} Environment | |
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: "Install UV and Pip" | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install uv | |
| - name: "Resolve Project Dependencies Using UV" | |
| run: | | |
| pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}' | |
| uv pip compile pyproject.toml --output-file requirements.txt | |
| popd | |
| shell: bash | |
| - name: "Install Dependencies Using Pip" | |
| shell: bash | |
| run: | | |
| pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}' | |
| pip install -r requirements.txt --target=".python_packages/lib/site-packages" | |
| popd | |
| - name: Upload artifact for deployment job | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: functionsapp | |
| path: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }} | |
| include-hidden-files: true | |
| build-and-publish-web: | |
| runs-on: "ubuntu-latest" | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 | |
| - name: Log in to registry | |
| uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 | |
| 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@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 | |
| with: | |
| context: ./app | |
| push: true | |
| tags: ccomreg.azurecr.io/${{ secrets.REGISTRY_USERNAME_DEV }}/latest:${{ github.sha }} | |
| file: ./app/api/Dockerfile | |
| build-and-publish-next-app: | |
| runs-on: ubuntu-latest | |
| environment: dev | |
| env: | |
| BACKEND_ORIGIN: ${{ secrets.BACKEND_ORIGIN }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Use Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: npm install and build | |
| run: | | |
| npm i --workspaces=false | |
| working-directory: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} | |
| - name: Cache .next/cache | |
| uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| env: | |
| cache-name: cache-node-modules | |
| with: | |
| path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/.next/cache | |
| key: nextjs | $(Agent.OS) | ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/package-lock.json | |
| - name: Build | |
| run: npm run build --workspaces=false | |
| working-directory: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} | |
| env: | |
| BODY_SIZE_LIMIT: ${{ vars.BODY_SIZE_LIMIT }} | |
| - name: Copy Static Assets | |
| run: | | |
| cp -r .next/static .next/standalone/.next/ | |
| cp -r public .next/standalone/ | |
| working-directory: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} | |
| - name: Publish webapp artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/.next/standalone | |
| name: frontendwebapp | |
| include-hidden-files: true | |
| build-and-publish-airflow: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| steps: | |
| - name: Check out the repo | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 | |
| - name: Docker Login | |
| uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | |
| with: | |
| registry: ${{ env.registry }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set timestamp env var | |
| run: echo "RUN_TIMESTAMP=$(TZ="Etc/UTC" date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV | |
| # Tag and build webserver of airflow | |
| - name: Extract webserver Docker metadata | |
| id: airflow_webserver_meta | |
| uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 | |
| with: | |
| images: ${{ env.registry }}/${{ env.repo-owner }}/${{ env.app-name }}/airflow-webserver | |
| tags: | | |
| ${{ github.event.release.tag_name }} | |
| ${{ github.sha }} | |
| ${{ env.RUN_TIMESTAMP }} | |
| - name: Build and push webserver image | |
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 | |
| with: | |
| context: ./app/airflow | |
| file: ./app/airflow/Dockerfile | |
| build-args: AIRFLOW_COMPONENT=webserver | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ${{ steps.airflow_webserver_meta.outputs.tags }} | |
| # Tag and build scheduler of airflow | |
| - name: Extract scheduler Docker metadata | |
| id: scheduler_meta | |
| uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 | |
| with: | |
| images: ${{ env.registry }}/${{ env.repo-owner }}/${{ env.app-name }}/airflow-scheduler | |
| tags: | | |
| ${{ github.event.release.tag_name }} | |
| ${{ github.sha }} | |
| ${{ env.RUN_TIMESTAMP }} | |
| - name: Build and push scheduler image | |
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 | |
| with: | |
| context: ./app/airflow | |
| file: ./app/airflow/Dockerfile | |
| build-args: AIRFLOW_COMPONENT=scheduler | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ${{ steps.scheduler_meta.outputs.tags }} | |
| # Deploy Workers Production | |
| deploy-workers-production: | |
| runs-on: ubuntu-latest | |
| needs: build-and-publish-workers | |
| environment: production | |
| steps: | |
| - name: Download artifact from build job | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| path: functionsapp | |
| name: functionsapp | |
| - name: "Run Azure Functions Action" | |
| uses: Azure/functions-action@0bd707f87c0b6385742bab336c74e1afc61f6369 # v1.5.3 | |
| id: fa | |
| with: | |
| app-name: ${{ vars.AZURE_FUNCTIONS_NAME }} | |
| slot-name: "production" | |
| package: ${{ github.workspace }}/functionsapp | |
| publish-profile: ${{ secrets.AZURE_FUNCAPP_PUBLISH_PROFILE }} | |
| # Deploy Web App Production | |
| deploy-web-production: | |
| runs-on: ubuntu-latest | |
| needs: [build-and-publish-web, 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@2fdd5c3ebb4e540834e86ecc1f6fdcd5539023ee # v3.0.2 | |
| with: | |
| app-name: ${{ vars.AZURE_WEBAPP_NAME }} | |
| slot-name: "production" | |
| publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} | |
| images: "ccomreg.azurecr.io/${{ secrets.REGISTRY_USERNAME_DEV }}/latest:${{ github.sha }}" | |
| # Deploy Next.js Client App Production | |
| deploy-next-production: | |
| runs-on: ubuntu-latest | |
| needs: [build-and-publish-next-app, deploy-web-production] | |
| environment: production | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Download artifact from build job | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| path: frontendwebapp | |
| name: frontendwebapp | |
| - name: Deploy to Azure WebApp | |
| uses: azure/webapps-deploy@2fdd5c3ebb4e540834e86ecc1f6fdcd5539023ee # v3.0.2 | |
| with: | |
| app-name: ${{ vars.AZURE_WEBAPP_NEXT_NAME }} | |
| publish-profile: ${{ secrets.AZURE_WEBAPP_NEXT_PUBLISH_PROFILE }} | |
| package: ${{ github.workspace }}/frontendwebapp | |
| # Deploy Airflow Webserver Production | |
| deploy-airflow-webserver-production: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| needs: [build-and-publish-airflow] | |
| environment: | |
| name: "production" | |
| url: ${{ steps.deploy-airflow-webserver-production.outputs.webapp-url }} | |
| steps: | |
| - name: Deploy to Azure Web App | |
| id: deploy-airflow-webserver-production | |
| uses: azure/webapps-deploy@2fdd5c3ebb4e540834e86ecc1f6fdcd5539023ee # v3.0.2 | |
| with: | |
| app-name: ${{ vars.AIRFLOW_WEBSERVER_NAME }} | |
| publish-profile: ${{ secrets.AIRFLOW_WEBSERVER_PUBLISH_PROFILE }} | |
| images: ${{ env.registry }}/${{ env.repo-owner }}/${{ env.app-name }}/airflow-webserver:${{ github.sha }} | |
| # Deploy Airflow Scheduler Production | |
| deploy-airflow-scheduler-production: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| needs: [build-and-publish-airflow] | |
| environment: | |
| name: "production" | |
| url: ${{ steps.deploy-airflow-scheduler-production.outputs.webapp-url }} | |
| steps: | |
| - name: Deploy to Azure Web App | |
| id: deploy-airflow-scheduler-production | |
| uses: azure/webapps-deploy@2fdd5c3ebb4e540834e86ecc1f6fdcd5539023ee # v3.0.2 | |
| with: | |
| app-name: ${{ vars.AIRFLOW_SCHEDULER_NAME }} | |
| publish-profile: ${{ secrets.AIRFLOW_SCHEDULER_PUBLISH_PROFILE }} | |
| images: ${{ env.registry }}/${{ env.repo-owner }}/${{ env.app-name }}/airflow-scheduler:${{ github.sha }} |