Skip to content

Feature/ex4 #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c6585ec
Remove pages YAML file
sven-pohl Oct 29, 2024
5758ecd
Add first workflow YAML file
sven-pohl Oct 29, 2024
cb92614
Update character limit for message text field
sven-pohl Oct 29, 2024
4d66356
Merge pull request #9 from sven-pohl/features/8_message_length
maras28 Oct 29, 2024
6cb1bbf
Add workflow YAML file for Azure Bicep deployment
sven-pohl Oct 29, 2024
bd79bd4
Update deploy.yml
sven-pohl Oct 29, 2024
b1cf0ac
Update main.bicep with new resource definitions
sven-pohl Oct 29, 2024
3f4d219
Refactor Azure Bicep deployment workflow
sven-pohl Oct 29, 2024
ca8b189
Update target environment to prod in deploy.yml
sven-pohl Oct 29, 2024
6d72b8b
Create dotnet-deployment.yml
sven-pohl Oct 30, 2024
b3e89a3
Update dotnet-deployment.yml to specify project paths for restore, bu…
sven-pohl Oct 30, 2024
5099c7b
Add Dockerfile for .NET 8 SDK and runtime setup
sven-pohl Oct 30, 2024
36f5d32
Update error message for message length validation to reflect correct…
sven-pohl Oct 30, 2024
edf5d70
Add Docker build and push steps to dotnet-deployment.yml
sven-pohl Oct 30, 2024
6021458
Fix typo in exception documentation for message length validation
sven-pohl Oct 30, 2024
074f51f
Replace Dockerfile in RazorPagesTestSample with a new build and runti…
sven-pohl Oct 30, 2024
90aa718
Add deployment job to Azure in dotnet-deployment.yml
sven-pohl Oct 30, 2024
4864ff1
Update panel titles and button formatting in Index.cshtml
sven-pohl Oct 30, 2024
98b1e5b
Update Azure deployment configuration with new environment URL and ap…
sven-pohl Oct 30, 2024
cbd0548
Update panel title in Index.cshtml for clarity
sven-pohl Oct 30, 2024
bb85370
Add deployment jobs for test and production environments in dotnet-de…
sven-pohl Oct 30, 2024
ba25835
Update button text in Index.cshtml for improved clarity
sven-pohl Oct 30, 2024
6b8a2eb
Add environment variables for Docker deployment in dotnet-deployment.yml
sven-pohl Oct 30, 2024
ab1b16e
Update button text in Index.cshtml for brevity
sven-pohl Oct 30, 2024
7294f1f
Add GitHub Actions script to notify on workflow failure
sven-pohl Oct 30, 2024
3b4c0d7
Update button text in Index.cshtml for improved clarity
sven-pohl Oct 30, 2024
b7b8f77
Add CODEOWNERS file to specify repository ownership
sven-pohl Oct 30, 2024
d437864
Update button text in Index.cshtml for brevity
sven-pohl Oct 30, 2024
0d73d32
Update CODEOWNERS to include additional owner for clarity
sven-pohl Oct 30, 2024
05bdda9
Update panel title in Index.cshtml for improved clarity
sven-pohl Oct 30, 2024
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
34 changes: 34 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Azure Bicep

on: workflow_dispatch

env:
targetEnv: prod

jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
steps:
# Checkout code
- uses: actions/checkout@main

# Log into Azure
- uses: azure/[email protected]
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true

# Deploy ARM template
- name: Run ARM deploy
uses: azure/arm-deploy@v1
with:
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resourceGroupName: ${{ secrets.AZURE_RG }}
template: ./src/InfrastructureAsCode/main.bicep
parameters: environment=${{ env.targetEnv }}
134 changes: 134 additions & 0 deletions .github/workflows/dotnet-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: .NET

env:
registryName: kqrfo3r42nm3umpnpreg.azurecr.io
repositoryName: techexcel/dotnetcoreapp
dockerFolderPath: ./src/Application/src/RazorPagesTestSample
tag: ${{ github.run_number }}

on:
push:
branches: ["main"]
paths: src/Application/**
pull_request:
branches: ["main"]
paths: src/Application/**
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
- name: Build
run: dotnet build --no-restore src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
- name: Test
run: dotnet test --no-build --verbosity normal src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj
- uses: actions/github-script@v6
if: failure()
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
let body = "${{ env.build_name }} Workflow Failure \n Build Number: ${{ github.run_number }} \n Build Log: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} \n SHA: [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) \n";
github.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "${{ env.build_name }} Workflow ${{ github.run_number }} Failed! ",
body: body
});

dockerBuildPush:
runs-on: ubuntu-latest
needs: build

steps:
- uses: actions/checkout@v3

- name: Docker Login
# You may pin to the exact commit or the version.
# uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
uses: docker/[email protected]
with:
# Server address of Docker registry. If not set then will default to Docker Hub
registry: ${{ secrets.ACR_LOGIN_SERVER }}
# Username used to log against the Docker registry
username: ${{ secrets.ACR_USERNAME }}
# Password or personal access token used to log against the Docker registry
password: ${{ secrets.ACR_PASSWORD }}
# Log out from the Docker registry at the end of a job
logout: true

- name: Docker Build
run: docker build -t $registryName/$repositoryName:$tag --build-arg build_version=$tag $dockerFolderPath

- name: Docker Push
run: docker push $registryName/$repositoryName:$tag

deploy-to-dev:
runs-on: ubuntu-latest
needs: dockerBuildPush
environment:
name: dev
url: https://kqrfo3r42nm3u-dev.azurewebsites.net/

steps:
- name: "Login via Azure CLI"
uses: azure/[email protected]
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- uses: azure/webapps-deploy@v2
with:
app-name: "kqrfo3r42nm3u-dev"
images: kqrfo3r42nm3umpnpreg.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}

deploy-to-test:
runs-on: ubuntu-latest
needs: deploy-to-dev
environment:
name: test
url: https://kqrfo3r42nm3u-test.azurewebsites.net/

steps:
- uses: actions/checkout@v3

- name: "Login via Azure CLI"
uses: azure/[email protected]
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- uses: azure/webapps-deploy@v2
with:
app-name: "kqrfo3r42nm3u-test"
images: kqrfo3r42nm3umpnpreg.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}

deploy-to-prod:
runs-on: ubuntu-latest
needs: deploy-to-test
environment:
name: prod
url: https://kqrfo3r42nm3u-prod.azurewebsites.net/

steps:
- uses: actions/checkout@v3

- name: "Login via Azure CLI"
uses: azure/[email protected]
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- uses: azure/webapps-deploy@v2
with:
app-name: "kqrfo3r42nm3u-prod"
images: kqrfo3r42nm3umpnpreg.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}
56 changes: 56 additions & 0 deletions .github/workflows/first-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# The name of the job is what will display on the GitHub repository in the Actions tab.
name: First Workflow

# The 'on' section tells GitHub under what conditions we want to run this workflow.
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
# Common scenarios include:
# workflow-dispatch (manual execution)
# issues
# push
# pull_request
# schedule
on:
workflow_dispatch:
issues:
types: [opened]

# This section covers the work to perform.
# We include one or more jobs in this section.
jobs:
# Each individual job will include details like execution order,
# pre-requisite jobs, and execution platform.
job1:
# We can run jobs on GitHub hosted VM runners in Windows, Ubuntu, and Mac OS.
# We can also run jobs on self-hosted hardware.
runs-on: ubuntu-latest

# Each job contains one or more steps. A step needs to have at least a name and a command.
steps:
- name: Step one
# The 'run' command executes a shell or command script. Because this is Ubuntu, the
# default run command will be /bin/bash
run: echo "Log from step one"
# This section does not appear in the solution file but demonstrates how to set
# custom variables that will be available in the run script.
env:
VARIABLE_NAME: value
- name: Step two
run: echo "Log from step two"

job2:
# Job 2 will only run after job 1 completes.
# Removing this 'needs' section would make the jobs run simultaneously.
needs: job1
runs-on: ubuntu-latest

steps:
- name: Cowsays
# The 'uses' command executes a remote GitHub action.
# A command like mscoutermarsh/cowsays-action means you can
# find this code at https://github.com/mscoutermarsh/cowsays-action
uses: mscoutermarsh/cowsays-action@master
# The 'with' block includes parameters that the workflow will pass
# to this action. Parameters are all in key-value format.
with:
text: "Ready for prod--ship it!"
color: "magenta"
62 changes: 0 additions & 62 deletions .github/workflows/pages.yml

This file was deleted.

16 changes: 14 additions & 2 deletions src/Application/src/RazorPagesTestSample/Data/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@ public class Message
{
public int Id { get; set; }

[Required]
/// <summary>
/// Gets or sets the text of the message.
/// </summary>
/// <value>
/// The text content of the message, limited to 250 characters.
/// </value>
/// <remarks>
/// The text must be a valid string and is required. If the text exceeds 250 characters, an error message will be displayed.
/// </remarks>
/// <exception cref="ValidationException">
/// Thrown when the text exceeds 250 characters or is not provided.
/// </exception>
/// /// /// /// /// /// /// /// /// /// /// /// [Required]
[DataType(DataType.Text)]
[StringLength(200, ErrorMessage = "There's a 200 character limit on messages. Please shorten your message.")]
[StringLength(250, ErrorMessage = "There's a 250 character limit on messages. Please shorten your message.")]
public string Text { get; set; }
}
#endregion
Expand Down
27 changes: 27 additions & 0 deletions src/Application/src/RazorPagesTestSample/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use the official .NET 8 SDK image as a build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

# Set the working directory
WORKDIR /app

# Copy the project file and restore dependencies
COPY *.csproj ./
RUN dotnet restore

# Copy the rest of the application code
COPY . ./

# Build the application
RUN dotnet publish -c Release -o out

# Use the official .NET 8 runtime image as a runtime stage
FROM mcr.microsoft.com/dotnet/aspnet:8.0

# Set the working directory
WORKDIR /app

# Copy the built application from the build stage
COPY --from=build /app/out .

# Set the entry point for the application
ENTRYPOINT ["dotnet", "RazorPagesTestSample.dll"]
11 changes: 7 additions & 4 deletions src/Application/src/RazorPagesTestSample/Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<form method="post">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Add a message</h3>
<h3 class="panel-title">Add a new message</h3>
</div>
<div class="panel-body">
<div class="form-group">
Expand All @@ -36,15 +36,17 @@
<form method="post">
<div class="panel panel-default">
<div class="panel-heading clearfix">
<button type="submit" asp-page-handler="DeleteAllMessages" class="pull-right btn btn-danger">Clear All</button>
<button type="submit" asp-page-handler="DeleteAllMessages" class="pull-right btn btn-danger">Clear
All</button>
<h3 class="panel-title" style="line-height:2.1">Messages</h3>
</div>
<div class="panel-body">
<ul>
@foreach (var message in Model.Messages)
{
<li style="line-height:2.4">
<button type="submit" class="btn btn-danger" style="margin-bottom:2px" asp-page-handler="DeleteMessage" asp-route-id="@message.Id">Delete</button>
<button type="submit" class="btn btn-danger" style="margin-bottom:2px"
asp-page-handler="DeleteMessage" asp-route-id="@message.Id">Delete</button>
@message.Text
</li>
}
Expand All @@ -66,7 +68,8 @@
</div>
<div class="panel-body">
<div class="form-group">
<button type="submit" asp-page-handler="AnalyzeMessages" class="btn btn-default">Analyze</button>
<button type="submit" asp-page-handler="AnalyzeMessages"
class="btn btn-default">Analyze</button>
</div>
<div class="form-group">
@Model.MessageAnalysisResult
Expand Down
7 changes: 7 additions & 0 deletions src/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Code owners for the repository

* @sven-pohl @svpohl

# Specify sven-pohl as the owner for the /src/Application/ directory

/Application/ @sven-pohl @svpohl
Loading
Loading