Last active
December 12, 2019 03:57
-
-
Save justinyoo/babbc243f01051ca36d419d26e31fce6 to your computer and use it in GitHub Desktop.
Publishing Static Website to Azure Blob Storage via GitHub Actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Activate static website hosting feature | |
az storage blob service-properties update \ | |
--account-name <STORAGE_ACCOUNT_NAME> \ | |
--static-website true \ | |
--index-document index.html \ | |
--404-document 404/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
az storage blob upload-batch \ | |
-s dist \ | |
-d \$web \ | |
--account-name <STORAGE_ACCOUNT_NAME> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a new Azure Resource Group | |
az group create \ | |
-n <RESOURCE_GROUP_NAME> \ | |
-l <LOCATION> | |
# Create a new Azure Storage instance | |
az storage account create \ | |
-g <RESOURCE_GROUP_NAME> \ | |
-n <STORAGE_ACCOUNT_NAME> \ | |
-l <LOCATION> \ | |
--sku Standard_LRS \ | |
--kind StorageV2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
... | |
"primaryEndpoints": { | |
"blob": "https://<STORAGE_ACCOUNT_NAME>.blob.core.windows.net/", | |
"dfs": "https://<STORAGE_ACCOUNT_NAME>.dfs.core.windows.net/", | |
"file": "https://<STORAGE_ACCOUNT_NAME>.file.core.windows.net/", | |
"queue": "https://<STORAGE_ACCOUNT_NAME>.queue.core.windows.net/", | |
"table": "https://<STORAGE_ACCOUNT_NAME>.table.core.windows.net/", | |
"web": "https://<STORAGE_ACCOUNT_NAME>.<ARBITRARY_VALUE>.web.core.windows.net/" | |
}, | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the endpoint URL | |
az storage account show \ | |
-g <RESOURCE_GROUP_NAME> \ | |
-n <STORAGE_ACCOUNT_NAME> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: <WORKFLOW_NAME> | |
on: <EVENT> | |
jobs: | |
<JOB_NAME>: | |
runs-on: <RUNNER> | |
steps: | |
- name: <ACTION_NAME> | |
uses: <ACTION> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Static Web App to Azure Blob Storage | |
on: push | |
jobs: | |
build_and_publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@v1 | |
- name: Login to Azure | |
uses: Azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Install npm packages | |
shell: bash | |
run: | | |
cd $GITHUB_WORKSPACE/src/WebApp | |
npm install | |
- name: Build app | |
shell: bash | |
run: | | |
cd $GITHUB_WORKSPACE/src/WebApp | |
npm run build | |
- name: Test app | |
shell: bash | |
run: | | |
cd $GITHUB_WORKSPACE/src/WebApp | |
npm run test:unit | |
- name: Publish app | |
uses: Azure/cli@v1.0.0 | |
with: | |
azcliversion: latest | |
inlineScript: | | |
az storage blob upload-batch -s $GITHUB_WORKSPACE/src/WebApp/dist -d \$web --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build the web app | |
gridsome build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install gridsome | |
npm install -g @gridsome/cli | |
# Create a website | |
gridsome create WebApp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run the web app locally | |
npm run develop | |
# Build the web app | |
npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd WebApp | |
# Run the web app locally | |
gridsome develop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment