This action was inspired by Azure Storage Action
. I re-wrote the whole thing using node.js
With Azure Static Website Action
, you can automate your workflow to deploy files to Azure Blob Storage
- Checkout your Git repository content into Github Actions agent.
- Follow the tutorial to Create an Azure Storage Account
- Create an empty workflow (
.yml
file) in the.github/workflows/
folder of your repository. - Copy the sample workflow into your workflow file.
- Change
MyFolder
to the relative path where your files are. - Commit and push your repository.
- You should see a new GitHub Action started under Actions tab.
# 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 }}
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 theazure/login
action prior to this step, and specify thestorage-account-name
parameter. Make sure that the Azure AD identity has theStorage Account Contributor
andStorage Blob Data Contributor
roles on the storage account. -
If you want to use a storage account key, then specify the
storage-account-name
andstorage-account-key
parameters.