Skip to content

Instantly share code, notes, and snippets.

@benmccallum
Created April 19, 2020 14:32
Show Gist options
  • Save benmccallum/179f375f776ddc5a0b9c90f861ff0e0b to your computer and use it in GitHub Desktop.
Save benmccallum/179f375f776ddc5a0b9c90f861ff0e0b to your computer and use it in GitHub Desktop.
GitHub Action static site deployment to Azure Blog Storage fronted by a CDN
name: Deploy to Azure
on:
push:
branches:
- master
paths:
- 'ui/*'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: 'yarn install and build'
working-directory: ui
run: |
yarn install
yarn run build
- name: 'Azure Deploy'
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
# Deploy to blob storage
- run: |
az storage blob upload-batch -s "./ui/dist" -d \$web --account-name "myproject"
# Bust cache in CDN for selective paths/assets
- run: |
az cdn endpoint purge -g "myproject" -n "myproject" --profile-name "myproject" --no-wait --content-paths '/index.html' '/css/*' '/js/*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment