Skip to content

Merge Build Pipelines #90

Merge Build Pipelines

Merge Build Pipelines #90

Workflow file for this run

name: Deploy Website to Azure Storage Account and Purge CDN
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.2.0]
steps:
# =================================
# Build
# =================================
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
npm install
npm install -g gatsby-cli@2.12.21
- name: Build with Gatsby
run: gatsby build
# =================================
# Push
# =================================
- name: Azure upload
uses: azure/CLI@v1
with:
azcliversion: 2.0.72
inlineScript: |
az storage blob delete-batch -s "\$web" --connection-string "${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}"
az storage blob upload-batch -d "\$web" -s public --connection-string "${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}"
# =================================
# Purge CDN
# =================================
- name: Azure CDN Purge
uses: azure/CLI@v1
with:
azcliversion: 2.0.72
inlineScript: |
echo "Logging into Azure:"
az login --service-principal \
-u "${{ secrets.CLIENT_ID }}" \
-p "${{ secrets.CLIENT_SECRET }}" \
--tenant "${{ secrets.TENANT_ID }}" \
--query "[].{\"Available Subscriptions\":name}" \
--output table
echo 'Setting subscription to: "${{ secrets.SUBSCRIPTION_ID }}"'
az account set --subscription "${{ secrets.SUBSCRIPTION_ID }}"
echo "Purging CDN:"
az cdn endpoint purge --name ${{ secrets.AZURE_CDN_ENDPOINT }} \
--profile-name ${{ secrets.AZURE_CDN_PROFILE_NAME }} \
--content-paths "/*" \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--no-wait
echo "Logging out of Azure:"
az logout