Skip to content

Commit

Permalink
Provide Logic App that will post updates about Docker images in PR (#410
Browse files Browse the repository at this point in the history
)

Provide Logic App that will post updates about Docker images in PR.

Closes #392
  • Loading branch information
tomkerkhove authored Mar 18, 2019
1 parent 661155b commit a5fbfa5
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .azure-devops/bots-scraper-ci-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: $(Date:yyyyMMdd)$(Rev:.r)
resources:
- repo: self
trigger: none
variables:
LogicApp.Name: 'promitor-automation-github-ci-scraper'
GitHub.Repo.Owner: 'tomkerkhove'
GitHub.Repo.Name: 'promitor'
GitHub.Bot.Name: 'promitor-bot'
pool:
vmImage: vs2017-win2016
steps:
- task: qetza.replacetokens.replacetokens-task.replacetokens@3
displayName: 'Replace tokens in tooling'
inputs:
rootDirectory: 'deploy/automation/scraper/ci/'
targetFiles: azuredeploy.parameters.json
verbosity: detailed
actionOnMissing: fail

- task: AzureResourceGroupDeployment@2
displayName: 'Deploy CI bot for Docker Hub updates'
inputs:
azureSubscription: 'Visual Studio Enterprise (0f9d7fea-99e8-4768-8672-06a28514f77e)'
resourceGroupName: promitor
location: 'West Europe'
csmFile: 'deploy/automation/scraper/ci/azuredeploy.json'
csmParametersFile: 'deploy/automation/scraper/ci/azuredeploy.parameters.json'





184 changes: 184 additions & 0 deletions deploy/automation/scraper/ci/azuredeploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"LogicApp.Name": {
"type": "string",
"maxLength": 80,
"metadata": {
"description": "Name of the Logic App that will handle new Docker Hub webhooks"
}
},
"GitHub.Repo.Owner": {
"type": "string",
"defaultValue": "tomkerkhove",
"metadata": {
"description": "Name of the owner for the GitHub repo"
}
},
"GitHub.Repo.Name": {
"type": "string",
"defaultValue": "promitor",
"metadata": {
"description": "Name of the GitHub repo"
}
},
"GitHub.Bot.Name": {
"type": "string",
"defaultValue": "promitor-bot",
"metadata": {
"description": "Name of the GitHub account that will act as a bot"
}
},
"GitHub.Bot.Password": {
"type": "securestring",
"metadata": {
"description": "Password to authenticate with for the GitHub account that will act as a bot"
}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2016-06-01",
"name": "[parameters('LogicApp.Name')]",
"location": "[resourceGroup().location]",
"properties": {
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Define_GitHub_comment_text": {
"inputs": "Docker image for this PR was built and is available on [Docker Hub](@{triggerBody()?['repository']?['repo_url']}).\n\nYou can pull it locally via the CLI:\n```shell\ndocker pull @{triggerBody()?['repository']?['repo_name']}:@{triggerBody()?['push_data']?['tag']}\n```",
"runAfter": {
"Determine_GitHub_Issue_Id": [
"Succeeded"
]
},
"type": "Compose"
},
"Determine_GitHub_Issue_Id": {
"inputs": "@replace(toLower(triggerBody()?['push_data']?['tag']), 'pr', '')",
"runAfter": {},
"type": "Compose"
},
"HTTP": {
"inputs": {
"authentication": {
"password": "[parameters('GitHub.Bot.Password')]",
"type": "Basic",
"username": "[parameters('GitHub.Bot.Name')]"
},
"body": {
"body": "@{outputs('Define_GitHub_comment_text')}"
},
"method": "POST",
"uri": "@{concat('https://api.github.com/repos/', parameters('GitHub.Repo.Owner'),'/', parameters('GitHub.Repo.Name'),'/issues/', outputs('Determine_GitHub_Issue_Id'),'/comments')}"
},
"runAfter": {
"Define_GitHub_comment_text": [
"Succeeded"
]
},
"type": "Http"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"GitHub.Repo.Owner": {
"defaultValue": "[parameters('GitHub.Repo.Owner')]",
"type": "string"
},
"GitHub.Repo.Name": {
"defaultValue": "[parameters('GitHub.Repo.Name')]",
"type": "string"
}
},
"triggers": {
"manual": {
"inputs": {
"schema": {
"properties": {
"callback_url": {
"type": "string"
},
"push_data": {
"properties": {
"images": {
"type": "array"
},
"pushed_at": {
"type": "integer"
},
"pusher": {
"type": "string"
},
"tag": {
"type": "string"
}
},
"type": "object"
},
"repository": {
"properties": {
"comment_count": {
"type": "integer"
},
"date_created": {
"type": "integer"
},
"description": {
"type": "string"
},
"full_description": {
"type": "string"
},
"is_official": {
"type": "boolean"
},
"is_private": {
"type": "boolean"
},
"is_trusted": {
"type": "boolean"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"owner": {
"type": "string"
},
"repo_name": {
"type": "string"
},
"repo_url": {
"type": "string"
},
"star_count": {
"type": "integer"
},
"status": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
},
"dependsOn": []
}
]
}
21 changes: 21 additions & 0 deletions deploy/automation/scraper/ci/azuredeploy.parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json",
"contentVersion": "1.0.0.0",
"parameters": {
"LogicApp.Name": {
"value": "#{LogicApp.Name}#"
},
"GitHub.Repo.Owner": {
"value": "#{GitHub.Repo.Owner}#"
},
"GitHub.Repo.Name": {
"value": "#{GitHub.Repo.Name}#"
},
"GitHub.Bot.Name": {
"value": "#{GitHub.Bot.Name}#"
},
"GitHub.Bot.Password": {
"value": "#{GitHub.Bot.Password}#"
}
}
}

0 comments on commit a5fbfa5

Please sign in to comment.