How-To Deploy the Hugo Web App with GitHub Actions

Sep 4, 2025 min read

This guide explains how to use and configure the Azure Static Web Apps CI/CD workflow. This workflow automates the deployment of your website to Azure Static Web Apps.

Prerequisites

  1. An Azure Static Web Apps instance
  2. Repository variables including AZURE_STATIC_WEB_APPS_API_TOKEN configured in your GitHub repository
    • This can be found in your Azure Static Web Apps resource
    • Add it under repository Settings → Secrets and variables → Actions → Variables

Directory Structure

.
├── .github/
│   └── workflows/
│       └── deploy-app.yml
└── website/           # Source code location
    └── public/        # Build output location

Workflow Details

Build and Deploy Job

This job handles the main deployment process:

  1. Checkout: Clones your repository with submodules

    - uses: actions/checkout@v3
      with:
        submodules: true
        lfs: false
    
  2. Build and Deploy: Uses Azure’s official action

    - uses: Azure/static-web-apps-deploy@v1
      with:
        azure_static_web_apps_api_token: ${{ vars.AZURE_STATIC_WEB_APPS_API_TOKEN }}
        repo_token: ${{ secrets.GITHUB_TOKEN }}
        action: "upload"
        app_location: "/website"
        output_location: "public"
    
  • app_location: Points to /website directory containing source code
  • output_location: Points to public directory containing built files
  • api_location: Currently not used (empty string)

Close Pull Request Job

The _Close Pull Request job automatically closes the pull request that triggered the build and deployment. When a pull request is opened, the Azure Static Web Apps GitHub Action builds and deploys the app to a staging environment. Afterward, the Close Pull Request job checks if the pull request is still open and closes it with a completion message.

- uses: Azure/static-web-apps-deploy@v1
  with:
    azure_static_web_apps_api_token: ${{ vars.AZURE_STATIC_WEB_APPS_API_TOKEN }}
    action: "close"

Additional Resources