Skip to content
upload-cloud

GitHub Action

Azure Static Website

v3 Latest version

Azure Static Website

upload-cloud

Azure Static Website

Deploy files to Azure Blob Storage Container using a connection string

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Azure Static Website

uses: tibor19/static-website-deploy@v3

Learn more about this action in tibor19/static-website-deploy

Choose a version

Azure Static Website Action

This action was inspired by Azure Storage Action. I re-wrote the whole thing using node.js

Deploy Files to Azure Blob Storage

With Azure Static Website Action, you can automate your workflow to deploy files to Azure Blob Storage

End-to-End Sample Workflows

Dependencies on other Github Actions

  • Checkout your Git repository content into Github Actions agent.

Create Azure Storage Account and deploy static website using GitHub Actions

  1. Follow the tutorial to Create an Azure Storage Account
  2. Create an empty workflow (.yml file) in the .github/workflows/ folder of your repository.
  3. Copy the sample workflow into your workflow file.
  4. Change MyFolder to the relative path where your files are.
  5. Commit and push your repository.
  6. You should see a new GitHub Action started under Actions tab.

Sample workflow to deploy a Static Web Site to Azure Blob Storage

# File: .github/workflows/workflow.yml

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps: 
    - name: Checkout the code
      uses: actions/checkout@v3
    - name: Deploy the website
      uses: tibor19/static-website-deploy@v2
      with:
        enabled-static-website: 'true'
        folder: 'MyFolder'
        connection-string: ${{ secrets.CONNECTION_STRING }}

Configure connection string:

For any credentials like Azure Service Principal, Publish Profile, Connection Strings, etc add them as secrets in the GitHub repository and then use them in the workflow.

The above example uses the Connection String of your Azure Storage Account.

There are several ways to connect to your Azure Storage Account:

  • If you are using a connection string, you can use the following steps to configure the secret:

    • Follow the tutorial Configure Azure Storage connection strings.
    • Define a new secret as part of your repository or organization settings.
    • Give the secret a name ex CONNECTION_STRING.
    • Paste the connection string file into the secret's value field.
  • If you want to use an Azure AD identity, you need call az login, or run the azure/login action prior to this step, and specify the storage-account-name parameter. Make sure that the Azure AD identity has the Storage Account Contributor and Storage Blob Data Contributor roles on the storage account.

  • If you want to use a storage account key, then specify the storage-account-name and storage-account-key parameters.