Skip to main content

Static Web Apps (SWA)

Publish Static Web App with GitHub CI/CD

  1. Create a Static Web App resource in Azure.

  2. If password protection is required, choose the Standard Tier.

    alt text

  3. Choose the GitHub repository's account/organization.

  4. Choose the repository.

  5. Choose the branch.

    alt text

  6. Accept all other defaults and click through until you can click Create.

  7. To assign a password: After the resource is finished creating, go to Configuration and change the setting so that Password is required for both staging and production environments.

Move a SWA to a different GH Repository

If you need the SWA to be published from a different GH repository, you can follow these steps:

  1. In the new repository, create two nested subdirectories (if they don't exist) under the root directory like .github/workflows/
  2. Go to the old directory under .github/workflows/ and grab the proper workflow file.
  3. Move the old workflow file to the new location defined in step 1.
  4. Open the SWA in Azure Portal.
  5. At the top of the main page for the SWA resource, click on Manage deployment token and copy the token.
  6. Go to the repository in github.com, click on settings, scroll down in the left nav bar and select Secrets and variables > Actions.
  7. Click New repository secret and paste the copied Azure token into the Secret * field.
  8. Before submitting, open another browser and go to the same page in the old repository. Copy the Name * field from the old repository's secret and paste it in for the name in the new repository.
  9. Click Add secret to submit it.
  10. Clean up:
    1. Remove the secret from the old repository.
    2. Remove the workflow yml file from the old repository.