Skip to content

Benoit feature #86

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 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2f8b3ee
clean
bmoussaud Oct 29, 2024
dcd5dcd
first workslfow
bmoussaud Oct 29, 2024
7e6569f
job2
bmoussaud Oct 29, 2024
3804524
fix job 2
bmoussaud Oct 29, 2024
5480bb5
job 1 then job 2
bmoussaud Oct 29, 2024
a81c50b
on source opened
bmoussaud Oct 29, 2024
781637e
Resolve #9: Update Message.cs to improve data handling
bmoussaud Oct 29, 2024
fef451d
Merge pull request #10 from bmoussaud/Issue9
bmoussaud Oct 29, 2024
a9cc9a8
deploy
bmoussaud Oct 29, 2024
607b2c1
Merge branch 'main' of https://github.com/bmoussaud/TechExcel-Acceler…
bmoussaud Oct 29, 2024
58c8b6d
update deploy
bmoussaud Oct 29, 2024
31f1b44
feat: add deploy workflow
bmoussaud Oct 29, 2024
122114a
add permissions
bmoussaud Oct 29, 2024
01f7198
json
bmoussaud Oct 29, 2024
c0aa65a
remvve cred
bmoussaud Oct 29, 2024
5bbf4da
add env env:
bmoussaud Oct 29, 2024
abacc64
rerun2
bmoussaud Oct 29, 2024
09ebb9e
updated bicep
bmoussaud Oct 29, 2024
24791bc
1V3
bmoussaud Oct 29, 2024
5c0b926
bacj to P0V3
bmoussaud Oct 29, 2024
d78420e
fix benoit
bmoussaud Oct 30, 2024
b443908
add dotnet deploy
bmoussaud Oct 30, 2024
3284637
fix deploy net
bmoussaud Oct 30, 2024
311ea9f
fix 2
bmoussaud Oct 30, 2024
0045f35
fix bmoussaudlebo
bmoussaud Oct 30, 2024
2f2322e
test
bmoussaud Oct 30, 2024
15d3704
advanced
bmoussaud Oct 30, 2024
8f456ba
move dockerfile
bmoussaud Oct 30, 2024
652d0b9
move dockerfile to the right folder
bmoussaud Oct 30, 2024
7a9349c
update env
bmoussaud Oct 30, 2024
12f38a9
Add CODEOWNERS file
bmoussaud Oct 30, 2024
3439fd7
feature and code owner
bmoussaud 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
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* @global-owner1 @global-owner2
/docs/ @docs-owner
/src/ @src-owner
README.md @readme-owner
*.js @js-owner
*.css @css-owner
/scripts/*.sh @scripts-owner
40 changes: 40 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Azure Bicep Advanced

on:
workflow_dispatch:
inputs:
appenv:
type: choice
description: Choose the target environment
options:
- dev
- test
- 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=${{ github.event.inputs.appenv }}
135 changes: 135 additions & 0 deletions .github/workflows/dotnet-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: .NET CI

env:
registryName: ut3bnazh3pnt6mpnpreg.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@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0

- 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://ut3bnazh3pnt6-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: 'ut3bnazh3pnt6-dev'
images: ut3bnazh3pnt6mpnpreg.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}

deploy-to-test:

runs-on: ubuntu-latest
needs: deploy-to-dev
environment:
name: test
url: https://ut3bnazh3pnt6-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: 'ut3bnazh3pnt6-test'
images: ut3bnazh3pnt6mpnpreg.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}

deploy-to-prod:

runs-on: ubuntu-latest
needs: deploy-to-test
environment:
name: prod
url: https://ut3bnazh3pnt6-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: 'ut3bnazh3pnt6-prod'
images: ut3bnazh3pnt6mpnpreg.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}
39 changes: 39 additions & 0 deletions .github/workflows/first-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: First Workflow

on:
workflow_dispatch:
issues:
types: [opened]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Run a one-line script
run: echo "Hello, GitHub Actions!"

job1:
runs-on: ubuntu-latest

steps:
- name: Step 1
run: echo "Step 1 complete!"

- name: Step 2
run: echo "Step 2 complete!"

job2:
runs-on: ubuntu-latest
needs: job1 # Ensure job2 waits for job1 to complete


steps:
- name: Cowsays Action
uses: mscoutermarsh/cowsays-action@master
with:
text: "Ready for prod–ship it!"
color: magenta
62 changes: 0 additions & 62 deletions .github/workflows/pages.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Solution/Exercise-03/Task-2/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch

env:
targetEnv: dev
targetEnv: test

jobs:
build-and-deploy:
Expand Down
11 changes: 10 additions & 1 deletion src/Application/src/RazorPagesTestSample/Data/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ public class Message
{
public int Id { get; set; }

/// <summary>
/// Gets or sets the message text.
/// </summary>
/// <value>
/// The message text, which is required and must be a string with a maximum length of 250 characters.
/// </value>
/// <exception cref="ValidationException">
/// Thrown when the text exceeds the 200 character limit.
/// </exception>
[Required]
[DataType(DataType.Text)]
[StringLength(200, ErrorMessage = "There's a 200 character limit on messages. Please shorten your message.")]
[StringLength(200, ErrorMessage = "There's a 250 character limit on messages. Please shorten your message.")]
public string Text { get; set; }
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build-env /app/out .
# Default ASP.NET port changed with .NET 8.0
ENV ASPNETCORE_HTTP_PORTS=80
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build-env /app/out .
# Default ASP.NET port changed with .NET 8.0
ENV ASPNETCORE_HTTP_PORTS=80
ENTRYPOINT ["dotnet", "RazorPagesTestSample.dll"]
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task<IActionResult> OnPostAnalyzeMessagesAsync()

if (Messages.Count == 0)
{
MessageAnalysisResult = "There are no messages to analyze.";
MessageAnalysisResult = "FEAURE BNEOIT There are no messages to analyze.";
}
else
{
Expand All @@ -86,7 +86,7 @@ public async Task<IActionResult> OnPostAnalyzeMessagesAsync()
}

var avgWordCount = Decimal.Divide(wordCount, Messages.Count);
MessageAnalysisResult = $"The average message length is {avgWordCount:0.##} words.";
MessageAnalysisResult = $"FEAURE BNEOIT The average message length is {avgWordCount:0.##} words.";
}

return RedirectToPage();
Expand Down
9 changes: 9 additions & 0 deletions src/InfrastructureAsCode/federated-credential-params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "GitHubDevOpsCredential3",
"issuer": "https://token.actions.githubusercontent.com",
"subject": "repo:bmoussaud/TechExcel-Accelerate-developer-productivity-with-GitHub-Copilot-and-Dev-Box:ref:refs/heads/main",
"description": "Deploy Azure resources from the TechExcel DevOps practices GitHub repo",
"audiences": [
"api://AzureADTokenExchange"
]
}
Loading
Loading