Skip to content

GitHub Action Build and Deploy

Chloe Lin [SSW] edited this page Feb 17, 2026 · 4 revisions

build and deploy

This GitHub Action builds and deploys the SSW.Rules application as a Docker container to Azure Web App.

flowchart TD
    A[Trigger] --> B{Trigger Type}
    B -->|Push to main| C
    B -->|Manual dispatch| C

    C[Start pipeline] --> D[Deploy Infrastructure]
    D --> E[Build and Push Container Image]
    E --> F[Deploy to Azure Web App]

    F --> G{Production?}
    G -->|Yes| H[Deploy to Slot]
    H --> I[Swap Slots]
    I --> J[Verify Deployment]
    G -->|No| J[Verify Deployment]

    J --> K{Production?}
    K -->|Yes| L[Crawl Sitemap]
    K -->|No| M[Done]

    L --> M[Done]

    style A fill:#f9f,stroke:#333,stroke-width:1px
    style B fill:#ccf,stroke:#333,stroke-width:1px
    style D fill:#bbf,stroke:#333,stroke-width:1px
    style E fill:#bbf,stroke:#333,stroke-width:1px
    style F fill:#bfb,stroke:#333,stroke-width:1px
    style J fill:#cfc,stroke:#333,stroke-width:1px
    style L fill:#ffd,stroke:#333,stroke-width:1px
    style M fill:#cfc,stroke:#333,stroke-width:1px


Loading

When It Runs

This workflow runs in two ways:

  • On push to main

    • Automatically deploys to the default environment (staging).
  • Manually via the Run workflow button

    • You can choose the target environment (staging or production).
    • You can optionally set the Tina content branch and a source branch name.

What It Does

The pipeline has three main stages:

  1. Deploy Infrastructure
  2. Build and Push Container Image
  3. Deploy to Azure Web App

1) Deploy Infrastructure

This stage ensures Azure resources exist and are up to date.

It:

  • Logs into Azure
  • Deploys or updates required infrastructure
  • Outputs values needed by later stages (ACR name, app service name, resource group, host name)

2) Build and Push Container Image

This stage builds the application as a Docker image and pushes it to Azure Container Registry (ACR).

It:

  • Checks out the source repository
  • Pulls content from the content repository
  • Generates required mapping files
  • Builds the application inside Docker
  • Pushes the container image to ACR

Notes:

  • Docker cache is disabled, so the image is built from scratch each time (fresh build).
  • The image is tagged based on the target environment.

3) Deploy to Azure Web App

This stage deploys the built container image to Azure Web App.

It:

  • Logs into Azure
  • Sets application settings (Auth0, API keys, build metadata, etc.)
  • Deploys the container image to the web app

Production vs Staging

Staging

  • Deploys directly to the staging web app
  • No slot swap is used

Production (Slot Deployment)

Production uses a safe slot-based rollout:

  1. Deploy the container to a pre-production slot
  2. Verify the deployment
  3. Swap the slot into production

This helps provide:

  • Minimal / no downtime
  • Safer releases
  • Easier rollback (swap back if needed)

Post-Deployment (Production Only)

If deploying to production, the workflow runs a sitemap crawl after deployment to keep the site index up to date.

This step does not run for staging.


Concurrency

Deployments are grouped by branch + environment.

If a new run starts for the same branch and environment:

  • The in-progress run is cancelled
  • Only the latest run continues

This prevents overlapping deployments.


Build Metadata

During deployment, the app is updated with build information such as:

  • Build timestamp
  • Build date
  • Commit hash
  • Version number
  • Deployment URL

This improves traceability and makes it easier to confirm what version is running.