Gitlab CI script to deploy a Azure Static Website

alandecastros

Alan Castro

Posted on May 24, 2020

Gitlab CI script to deploy a Azure Static Website

Before using this script you must have an Azure storage account created with the static website enabled.

In this example I have a javascript project that I build using npm.

Variables:

  • $AZ_STORAGE_CONNECTION_STRING

Here is the .gitlab-ci.yml.

stages:
  - build
  - deploy

build:
  stage: build
  image: node:10
  script:
    - npm install
    - npm run build
  only:
    - master
  artifacts:
    paths:
      - dist/

deploy:
  stage: deploy
  image: microsoft/azure-cli
  dependencies:
    - build
  script:
    - az storage blob delete-batch -s "\$web" --connection-string $AZ_STORAGE_CONNECTION_STRING
    - az storage blob upload-batch -d "\$web" -s dist --connection-string $AZ_STORAGE_CONNECTION_STRING
  only:
    - master

Hope it's useful!

💖 💪 🙅 🚩
alandecastros
Alan Castro

Posted on May 24, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related