DEV Community

loading...

Gitlab CI script to deploy a Azure Static Website

alandecastros profile image Alan Castro ・1 min read

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!

Discussion (1)

pic
Editor guide
Collapse
maymeow profile image
💜May Meow🌼

already trying to find something like this ;)