In order to automatically trigger new deployments using Azure Pipelines follow these instructions:
Add your deployment SSH private key to Azure as a secure file as
id_rsa_lagoon. For more information about Secure Files have a look at the Azure Documentation Site.
Add the following configuration to your
pool:vmImage: 'ubuntu-latest'stages:# .. other stages- stage: Deploycondition: and(succeeded(), in(variables['Build.SourceBranch'], 'refs/heads/staging', 'refs/heads/develop'))jobs:- job: DeployLagoonsteps:- task: [email protected]name: lagoonSshKeydisplayName: 'Download Lagoon SSH key'inputs:secureFile: id_rsa_lagoon- script: |curl -L "https://github.com/amazeeio/lagoon-cli/releases/download/0.9.2/lagoon-cli-0.9.2-linux-amd64" -o ./lagoonchmod +x ./lagoondisplayName: 'Download lagoon-cli'- script: ./lagoon login -i $(lagoonSshKey.secureFilePath)displayName: 'Log into Lagoon'- script: ./lagoon deploy branch -e $(Build.SourceBranchName) -p my-awesome-project -b $(Build.SourceBranchName) --forcedisplayName: 'Trigger deployment using lagoon-cli'
This will trigger a new deployment whenever changes are made on the
staging branch. Adjust these values accordingly so they fit your deployment strategy and configuration.
There may be a case where you want to push without a deployment. Make sure your commit message contains "
[skip deploy]" or "
[deploy skip]" and Lagoon will not trigger a deployment from that commit.