Deploy to Production (carrot.ac.uk) #43
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
| # Deploy to Production (carrot.ac.uk) | |
| # | |
| # This workflow deploys Docker images to the production environment. | |
| # It requires manual approval and validates image existence before deployment. | |
| # | |
| # When to use: | |
| # - Deploying stable releases to production | |
| # - Deploying edge images to production after testing (I don't recommend this though) | |
| # - Emergency deployments with specific image tags | |
| # | |
| # What it does: | |
| # - Validates that the specified image tag exists | |
| # - Deploys all services to production environment | |
| # - Requires manual approval (environment protection) | |
| # - Provides deployment summary | |
| name: Deploy to Production (carrot.ac.uk) | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| image_tag: | |
| description: 'Image tag to deploy (e.g., v4.0.1, v4.1.0, or specific commit SHA)' | |
| required: true | |
| env: | |
| app-name: carrot | |
| repo-owner: health-informatics-uon | |
| registry: ghcr.io | |
| permissions: | |
| contents: read | |
| jobs: | |
| validate-deployment: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Validate image tag | |
| run: | | |
| if [[ "${{ github.event.inputs.image_tag }}" == "" ]]; then | |
| echo "❌ Image tag is required" | |
| exit 1 | |
| fi | |
| echo "✅ Deploying image tag: ${{ github.event.inputs.image_tag }}" | |
| deploy-to-production: | |
| runs-on: ubuntu-latest | |
| environment: production | |
| needs: [validate-deployment] | |
| steps: | |
| # Check that images exist before deploying | |
| - uses: tyriis/docker-image-tag-exists@71a750a41aa78e4efb0842f538140c5df5b8166f # v2.1.0 | |
| with: | |
| registry: ${{ env.registry }} | |
| repository: ${{ env.repo-owner }}/${{ env.app-name }}/backend | |
| tag: ${{ github.event.inputs.image_tag }} | |
| - uses: tyriis/docker-image-tag-exists@71a750a41aa78e4efb0842f538140c5df5b8166f # v2.1.0 | |
| with: | |
| registry: ${{ env.registry }} | |
| repository: ${{ env.repo-owner }}/${{ env.app-name }}/frontend | |
| tag: ${{ github.event.inputs.image_tag }} | |
| - uses: tyriis/docker-image-tag-exists@71a750a41aa78e4efb0842f538140c5df5b8166f # v2.1.0 | |
| with: | |
| registry: ${{ env.registry }} | |
| repository: ${{ env.repo-owner }}/${{ env.app-name }}/airflow-webserver | |
| tag: ${{ github.event.inputs.image_tag }} | |
| - uses: tyriis/docker-image-tag-exists@71a750a41aa78e4efb0842f538140c5df5b8166f # v2.1.0 | |
| with: | |
| registry: ${{ env.registry }} | |
| repository: ${{ env.repo-owner }}/${{ env.app-name }}/airflow-scheduler | |
| tag: ${{ github.event.inputs.image_tag }} | |
| - name: Deploy Backend to Production | |
| 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: ${{ env.registry }}/${{ env.repo-owner }}/${{ env.app-name }}/backend:${{ github.event.inputs.image_tag }} | |
| - name: Deploy Frontend to Production | |
| uses: azure/webapps-deploy@2fdd5c3ebb4e540834e86ecc1f6fdcd5539023ee # v3.0.2 | |
| with: | |
| app-name: ${{ vars.AZURE_WEBAPP_NEXT_NAME }} | |
| slot-name: "production" | |
| publish-profile: ${{ secrets.AZURE_WEBAPP_NEXT_PUBLISH_PROFILE }} | |
| images: ${{ env.registry }}/${{ env.repo-owner }}/${{ env.app-name }}/frontend:${{ github.event.inputs.image_tag }} | |
| - name: Deploy Airflow Webserver to Production | |
| uses: azure/webapps-deploy@2fdd5c3ebb4e540834e86ecc1f6fdcd5539023ee # v3.0.2 | |
| with: | |
| app-name: ${{ vars.AIRFLOW_WEBSERVER_NAME }} | |
| slot-name: "production" | |
| publish-profile: ${{ secrets.AIRFLOW_WEBSERVER_PUBLISH_PROFILE }} | |
| images: ${{ env.registry }}/${{ env.repo-owner }}/${{ env.app-name }}/airflow-webserver:${{ github.event.inputs.image_tag }} | |
| - name: Deploy Airflow Scheduler to Production | |
| uses: azure/webapps-deploy@2fdd5c3ebb4e540834e86ecc1f6fdcd5539023ee # v3.0.2 | |
| with: | |
| app-name: ${{ vars.AIRFLOW_SCHEDULER_NAME }} | |
| slot-name: "production" | |
| publish-profile: ${{ secrets.AIRFLOW_SCHEDULER_PUBLISH_PROFILE }} | |
| images: ${{ env.registry }}/${{ env.repo-owner }}/${{ env.app-name }}/airflow-scheduler:${{ github.event.inputs.image_tag }} | |
| - name: Deployment Summary | |
| run: | | |
| echo "✅ Successfully deployed to production (carrot.ac.uk)" | |
| echo "📦 Image tag: ${{ github.event.inputs.image_tag }}" | |
| echo "🔗 Production URL: https://carrot.ac.uk" | |
| echo "📅 Deployment time: $(date -u)" |