Skip to content

Commit

Permalink
Public deployment for own use and sponsors (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
mburumaxwell authored Sep 29, 2023
1 parent dd9cb1b commit e75a393
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ In this repository you'll find:
3. Dependabot [server](./server/) in .NET/C#. See [docs](./docs/server.md).
4. Azure DevOps [Extension](https://marketplace.visualstudio.com/items?itemName=tingle-software.dependabot) and [source](./extension).

> The hosted version is available to sponsors (most, but not all). It includes hustle free runs where the infrastructure is maintained for you. Much like the GitHub hosted version. Alternatively, you can run and host your own [server](./docs/server.md). Once you sponsor, you can send out an email to an maintainer or wait till they reach out. This is meant to ease the burden until GitHub/Azure/Microsoft can get it working natively (which could also be never) and hopefully for free.
## Using a configuration file

Similar to the GitHub native version where you add a `.github/dependabot.yml` file, this repository adds support for the same official [configuration options](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file) via a file located at `.github/dependabot.yml`. This support is only available in the Azure DevOps extension and the [managed version](https://managd.dev). However, the extension does not currently support automatically picking up the file, a pipeline is still required. See [docs](./extension/README.md#usage).
Expand Down
125 changes: 125 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: '$(Date:yyyy)-$(Date:MM)-$(Date:dd)$(Rev:.r)'

trigger:
batch: true
branches:
include:
- main
- refs/tags/*

pr:
branches:
include:
- main
drafts: false
autoCancel: true
paths:
include:
- server/**
- azure-pipelines.yml
exclude:
- docs/**

stages:
- stage: Build
jobs:
- job: Build

pool:
vmImage: 'ubuntu-latest'

steps:
- checkout: self
fetchDepth: 0 # no shallow fetch, we need all the history for GitVersion to work

- task: gitversion/setup@0
displayName: Setup GitVersion
inputs:
versionSpec: '5.x'

- task: gitversion/execute@0
displayName: Determine Version
name: GitVersion
inputs:
useConfigFile: true
configFilePath: '$(Build.SourcesDirectory)/GitVersion.yml'

- task: replacetokens@3
displayName: 'Replace tokens in main.parameters.json'
inputs:
rootDirectory: '$(Build.SourcesDirectory)/server'
targetFiles: 'server/main.parameters.json'
actionOnMissing: fail
verbosity: detailed

# Compile bicep file to JSON to make it independent
- script: |
bicep build main.bicep --outfile main.json
displayName: 'Compile bicep file'
workingDirectory: $(Build.SourcesDirectory)/server
- task: CopyFiles@2
displayName: 'Copy files to drop folder'
inputs:
SourceFolder: $(Build.SourcesDirectory)/server
Contents: |
*.json
TargetFolder: $(Build.ArtifactStagingDirectory)/drop

- task: PublishPipelineArtifact@1
displayName: "Publish drop artifact"
inputs:
targetPath: $(Build.ArtifactStagingDirectory)/drop
artifactName: "drop"

- task: AzureCLI@2
displayName: "Validate Resources"
condition: |
and
(
succeeded(),
startsWith(variables['Build.SourceBranch'], 'refs/pull/')
)
inputs:
azureSubscription: $(azureConnection)
scriptType: bash
scriptLocation: inlineScript
inlineScript: >
az deployment group validate
--resource-group '$(resourceGroupName)'
--template-file $(Build.SourcesDirectory)/server/main.json
--parameters $(Build.SourcesDirectory)/server/main.parameters.json
- stage: Deploy
displayName: Deploy
dependsOn: Build
# only deploy non pr branches
condition: |
and
(
succeeded(),
not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))
)
jobs:
- deployment: Deploy
environment: Dependabot

pool:
vmImage: 'ubuntu-latest'

strategy:
runOnce:
deploy:
steps:

- task: AzureCLI@2
displayName: "Deploy Resources"
inputs:
azureSubscription: $(azureConnection)
scriptType: bash
scriptLocation: inlineScript
inlineScript: >
az deployment group create
--resource-group '$(resourceGroupName)'
--template-file $(Pipeline.Workspace)/drop/main.json
--parameters $(Pipeline.Workspace)/drop/main.parameters.json
18 changes: 18 additions & 0 deletions server/main.parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "dependabot"
},
"projectSetups": {
"value": "[{\"url\":\"#{System_TeamFoundationCollectionUri}##{System_TeamProject}#\", \"token\":\"${DependabotProjectToken}\",\"AutoComplete\":true}]"
},
"githubToken": {
"value": "#{GithubToken}#"
},
"imageTag": {
"value": "#{GITVERSION_SHORTSHA}#"
}
}
}

0 comments on commit e75a393

Please sign in to comment.