From 12c0086d6e07cd1320fcf23593f4ec5c7f4e10d1 Mon Sep 17 00:00:00 2001 From: Smith Date: Fri, 17 Jun 2022 03:09:56 +0200 Subject: [PATCH] add azure 1 click deployment support --- README.md | 2 + azuredeploy.json | 155 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 azuredeploy.json diff --git a/README.md b/README.md index dd1ae6b..7dcaaa3 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,8 @@ Check the wiki page for detailed instructions on [how to setup a self deploying [![Deploy to Heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) +[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fa-sync%2Fgame-server-watcher%2Fmaster%2Fazuredeploy.json) + ## Hosting Make sure all the [requirements](#requirements) are met! _**Protip:** check the node.js version with `node -v`._ diff --git a/azuredeploy.json b/azuredeploy.json new file mode 100644 index 0000000..03a6af1 --- /dev/null +++ b/azuredeploy.json @@ -0,0 +1,155 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "siteName": { + "type": "string", + "defaultValue": "Game Server Watcher", + "metadata": { + "description": "The name of the web app that you wish to create." + } + }, + "siteLocation": { + "type": "string", + "defaultValue": "[resourceGroup().location]", + "metadata": { + "description": "The location to use for creating the web app and hosting plan. It must be one of the Azure locations that support web apps." + } + }, + "secret": { + "type": "string", + "metadata": { + "description": "Admin secret" + } + }, + "refreshTimeMinutes": { + "type": "int", + "defaultValue": 5, + "minValue": 1, + "maxValue": 59, + "metadata": { + "description": "Game server info refresh interval in minutes [DEPRECETED]" + } + }, + "discordBotToken": { + "type": "string", + "metadata": { + "description": "Discord bot token" + } + }, + "telegramBotToken": { + "type": "string", + "metadata": { + "description": "Telegram bot token" + } + }, + "steamWebApiKey": { + "type": "string", + "metadata": { + "description": "Steam web API key" + } + }, + "repoUrl": { + "type": "string", + "metadata": { + "description": "Optional source repo URL." + } + }, + "branch": { + "type": "string", + "metadata": { + "description": "Optional source repo branch." + } + } + }, + "variables": { + "sku": "Free", + "skuCode": "F1", + "linuxFxVersion": "NODE|lts", + "hostingPlanName": "[format('AppServicePlan-{0}', parameters('webAppName'))]" + }, + "resources": [ + { + "apiVersion": "2021-02-01", + "name": "[variables('hostingPlanName')]", + "type": "Microsoft.Web/serverfarms", + "location": "[parameters('siteLocation')]", + "sku": { + "name": "[variables('skuCode')]", + "tier": "[variables('sku')]" + }, + "kind": "linux", + "properties": { + "name": "[variables('hostingPlanName')]" + } + }, + { + "apiVersion": "2021-02-01", + "name": "[parameters('siteName')]", + "type": "Microsoft.Web/sites", + "location": "[parameters('siteLocation')]", + "dependsOn": [ + "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]" + ], + "kind": "app,linux", + "properties": { + "serverFarmId": "[variables('hostingPlanName')]", + "siteConfig": { + "linuxFxVersion": "[parameters('linuxFxVersion')]" + } + }, + "resources": [ + { + "apiVersion": "2021-02-01", + "name": "web", + "type": "config", + "dependsOn": [ + "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]" + ], + "properties": { + "siteProperties": { + "webSocketsEnabled": true + } + } + }, + { + "apiVersion": "2021-02-01", + "name": "appsettings", + "type": "config", + "dependsOn": [ + "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]" + ], + "properties": { + "SECRET": "[parameters('secret')]", + "REFRESH_TIME_MINUTES": "[parameters('refreshTimeMinutes')]", + "DISCORD_BOT_TOKEN": "[parameters('discordBotToken')]", + "TELEGRAM_BOT_TOKEN": "[parameters('telegramBotToken')]", + "STEAM_WEB_API_KEY": "[parameters('steamWebApiKey')]", + "command": "bash scripts/azuredeploy.sh" + } + }, + { + "condition": "[contains(parameters('repoUrl'), 'http')]", + "apiVersion": "2021-02-01", + "name": "web", + "type": "sourcecontrols", + "dependsOn": [ + "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]", + "[concat('Microsoft.Web/Sites/', parameters('siteName'), '/config/web')]" + ], + "properties": { + "RepoUrl": "[parameters('repoUrl')]", + "branch": "[parameters('branch')]", + "IsManualIntegration": true + } + } + ] + } + ], + "outputs": { + "siteUri": { + "type": "string", + "value": "[concat('https://',reference(resourceId('Microsoft.Web/sites', parameters('siteName'))).hostNames[0])]" + } + } +} \ No newline at end of file