diff --git a/.github/workflows/deploy_infra.yml b/.github/workflows/deploy_infra.yml new file mode 100644 index 0000000..9279693 --- /dev/null +++ b/.github/workflows/deploy_infra.yml @@ -0,0 +1,22 @@ +name: Deploy Infrastructure + +on: + push: + branches: + - main + +jobs: + deploy_infra: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Login to Azure + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Deploy Bicep files + run: | + az deployment group create --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} --template-file ./infra/main.bicep --parameters appServiceName=${{ secrets.APP_SERVICE_NAME }} storageAccountName=${{ secrets.STORAGE_ACCOUNT_NAME }} diff --git a/infra/appservice.bicep b/infra/appservice.bicep new file mode 100644 index 0000000..641d147 --- /dev/null +++ b/infra/appservice.bicep @@ -0,0 +1,21 @@ +param appServiceName string +param location string = 'eastus' +param appServicePlanId string + +resource appService 'Microsoft.Web/sites@2021-02-01' = { + name: appServiceName + location: location + kind: 'app' + properties: { + serverFarmId: appServicePlanId + httpsOnly: true + } + siteConfig: { + appSettings: [ + { + name: 'WEBSITE_NODE_DEFAULT_VERSION' + value: '10.14.1' + } + ] + } +} diff --git a/infra/main.bicep b/infra/main.bicep new file mode 100644 index 0000000..7410fb8 --- /dev/null +++ b/infra/main.bicep @@ -0,0 +1,21 @@ +targetScope = 'resourceGroup' + +resource appService 'Microsoft.Web/sites@2021-02-01' = { + name: 'appServiceName' + location: 'location' + properties: { + serverFarmId: 'appServicePlanId' + } +} + +resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = { + name: 'storageAccountName' + location: 'location' + kind: 'StorageV2' + sku: { + name: 'Standard_LRS' + } + properties: { + accessTier: 'Hot' + } +} diff --git a/infra/storageaccount.bicep b/infra/storageaccount.bicep new file mode 100644 index 0000000..e850b87 --- /dev/null +++ b/infra/storageaccount.bicep @@ -0,0 +1,14 @@ +param storageAccountName string +param location string = 'eastus' + +resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = { + name: storageAccountName + location: location + kind: 'StorageV2' + sku: { + name: 'Standard_LRS' + } + properties: { + accessTier: 'Hot' + } +}