Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/Assignment1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Assignment 1

on:
workflow_dispatch:
push:
branches:
- Assignment1
paths:
- 'Assignment1/**'
- '.github/workflows/Assignment1.yml'

# Required for OIDC authentication
permissions:
id-token: write
contents: read

env:
DOTNET_VERSION: '8.0.x'
AZURE_WEBAPP_NAME: 'cscd396-jake-webapp'
WEBAPP_PACKAGE_PATH: 'Assignment1/WebApp'

jobs:
list-azure-resources:
name: Login and List Azure Resources
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Azure Login with OIDC
uses: azure/login@v2
with:
client-id: ${{ vars.CLIENT_ID }}
tenant-id: ${{ vars.TENANT_ID }}
subscription-id: ${{ vars.SUBSCRIPTION_ID }}

- name: Run Assignment1.ps1 - List Resources
shell: pwsh
run: |
./Assignment1/Assignment1.ps1

- name: Logout from Azure
if: always()
run: az logout

build-and-deploy-webapp:
name: Build and Deploy .NET Web App
runs-on: ubuntu-latest
needs: list-azure-resources

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Build and publish
run: |
dotnet publish ${{ env.WEBAPP_PACKAGE_PATH }}/WebApp.csproj \
--configuration Release \
--output ./publish

- name: Azure Login with OIDC
uses: azure/login@v2
with:
client-id: ${{ vars.CLIENT_ID }}
tenant-id: ${{ vars.TENANT_ID }}
subscription-id: ${{ vars.SUBSCRIPTION_ID }}

- name: Deploy to Azure App Service
uses: azure/webapps-deploy@v3
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
package: ./publish

- name: Logout from Azure
if: always()
run: az logout
20 changes: 20 additions & 0 deletions Assignment1/Assignment1.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Assignment 1 - Azure Resource Listing Script
# CSCD 396 - DevOps

# Your Azure Subscription ID
$subscription_id = "d7dc33ae-d588-44a6-bda7-3e08dbd66d6f"

# Set the active subscription
az account set --subscription $subscription_id

# List all resources in the subscription
Write-Host "=== All Resources in Subscription ==="
az resource list --subscription $subscription_id --output table

Write-Host ""
Write-Host "=== Resource Groups ==="
az group list --subscription $subscription_id --output table

Write-Host ""
Write-Host "=== Storage Accounts ==="
az storage account list --subscription $subscription_id --output table
8 changes: 8 additions & 0 deletions Assignment1/WebApp/Pages/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@page
@model IndexModel
@{
ViewData["Title"] = "Home";
}

<h1>CSCD 396 - Assignment 1</h1>
<p>Deployed to Azure App Service via GitHub Actions.</p>
8 changes: 8 additions & 0 deletions Assignment1/WebApp/Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace WebApp.Pages;

public class IndexModel : PageModel
{
public void OnGet() { }
}
11 changes: 11 additions & 0 deletions Assignment1/WebApp/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - CSCD 396</title>
</head>
<body>
@RenderBody()
</body>
</html>
3 changes: 3 additions & 0 deletions Assignment1/WebApp/Pages/_ViewImports.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@using WebApp
@namespace WebApp.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
3 changes: 3 additions & 0 deletions Assignment1/WebApp/Pages/_ViewStart.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}
12 changes: 12 additions & 0 deletions Assignment1/WebApp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRazorPages();

var app = builder.Build();

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.MapRazorPages();

app.Run();
9 changes: 9 additions & 0 deletions Assignment1/WebApp/WebApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

</Project>