Azure Devops and Azure App Service

This is an azure devops pipeline which uses Jekyll static generator to deploy a static site to Azure App Service, please ensure you create an Azure web app in this case a Linux Web App using PHP as a prerequisite

There are 2 stages Build and Deploy Build is used for building the site and Deploy stage deploys to Azure App Service in this case a Linux Web App


trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

stages:
- stage: Build
  jobs:
  - job: build  
    steps:
    - task: UseRubyVersion@0
      
      inputs:
       versionSpec: '>= 2.4'

    - script: gem install bundler
      displayName: 'Install Bundler'

    - script: 'bundle install' 
      displayName: 'Install Jekyll and Dependencies'

    - script: 'bundle exec jekyll build' 
      displayName: 'Build Jekyll Site'
      
    - task: CopyFiles@2
      displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
      inputs:
       SourceFolder: '_site'
       TargetFolder: '$(Build.ArtifactStagingDirectory)'

    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact: _site'
      inputs:
        pathtoPublish: '$(Build.ArtifactStagingDirectory)'
        artifactName: '_site'

- stage: Deploy
  displayName: 'Deploy Web App'
  dependsOn: Build
  condition: succeeded()
  jobs:
  - job: deploy
    pool:
      vmImage: ubuntu-latest
      environment: dev
    steps:
     - task: DownloadPipelineArtifact@2
       inputs:
        source: 'current'
        artifact: '_site'
        path: '$(Pipeline.Workspace)'
     - task: AzureRmWebAppDeployment@4
       inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: 'Test'
        appType: 'webAppLinux'
        WebAppName: 'blogtest1'
        packageForLinux: '$(Pipeline.Workspace)'
        RuntimeStack: 'PHP|8.1'