After following the steps below, you will be able to setup your Azure resources and deploy the Gatsby website!
- Create an Azure account (a free account can be obtained from https://azure.microsoft.com/en-us/free/)
- Create a new Resource Group in Azure Portal by clicking Navigation Pane | Resource groups | + Create
- Install the Azure CLI from https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
- Run
az login
- Follow the prompts to log in to Azure CLI
- Run
az account list
to find your Azure Subscriptions - Use the
name
field to identify the Azure Subscription you want to use - Save the
tenantId
value for later use - Run
az ad sp create-for-rbac --name sswwebsite --role contributor --scopes /subscriptions/<your.tenantId>/resourceGroups/<your.resourceGroup> --sdk-auth
- Replace <your.tenantId> with the saved tenantId
- Replace <your.resourceGroup> with the Resource Group name you created
- Save the
sswwebsite
credentials for later
Note: Steps 6 and 7 will need to be repeated (with different names) if you wish to publish to 2 different Resource Groups.
The GitHub actions in this repository require the correct secrets and environment secrets to successfully deploy to Azure.
-
Create two environments in GitHub:
- Staging
- Production
-
Setup each environment with the following secrets:
- AZURE_CREDENTIALS
- Set as the
sswwebsite
credentials from theSetup Azure CLI
section
- Set as the
- AZURE_RESOURCE_GROUP
- Set as the
resourceGroup
you created credentials for
- Set as the
- AZURE_APP_NAME
- Set as your desired prefix for your resources e.g.
sswwebsite
Note: Keep this a bit shorter (~10 characters) so as not to break the Azure resoruce character limit
- Set as your desired prefix for your resources e.g.
- AZURE_TENANT
- Set as the
tenantId
from theSetup Azure CLI
- Set as the
- CONTENT_BRANCH
- Set as the name of the branch to source content from in the content repository
- AZURE_CREDENTIALS
Once the GitHub environments are set up you have the opportunity to place protections on your production environment so that deploys can't happen accidentally.
Once all of the environment secrets are created, you are ready to reploy the required Azure Resources to your resource group.
In your GitHub repository
- Navigate to Actions | Deploy Azure Resources | Run workflow
- Click Run workflow
You're finally ready to deploy your static site to Azure!
- Navigate to Actions | Staging - Deploy Gatsby Site | Run workflow
- Click Run workflow
**Note: ** Running the Production - Deploy Gatsby Site
action will deploy the website to your production environment