Skip to content

Commit 7373b0d

Browse files
committed
Add exercise 5 task 4
1 parent 74bd35f commit 7373b0d

File tree

9 files changed

+203
-64
lines changed

9 files changed

+203
-64
lines changed

Media/0504_BuildSucceeded.png

20.9 KB
Loading

Media/0504_ErrorMessage.png

66.2 KB
Loading

Media/0504_RunWorkflow.png

48.6 KB
Loading

Media/0504_UnitTest.png

53.8 KB
Loading

Media/0504_ValuesDiffer.png

28.1 KB
Loading
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: .NET CI
2+
3+
env:
4+
registryName: {your_registry_name}.azurecr.io
5+
repositoryName: techexcel/dotnetcoreapp
6+
dockerFolderPath: ./src/Application/src/RazorPagesTestSample
7+
tag: ${{github.run_number}}
8+
9+
on:
10+
push:
11+
branches: [ main ]
12+
paths: src/Application/**
13+
pull_request:
14+
branches: [ main ]
15+
paths: src/Application/**
16+
# Allows you to run this workflow manually from the Actions tab
17+
workflow_dispatch:
18+
jobs:
19+
build:
20+
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v3
25+
- name: Setup .NET
26+
uses: actions/setup-dotnet@v3
27+
with:
28+
dotnet-version: 8.0
29+
30+
- name: Restore dependencies
31+
run: dotnet restore ./src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
32+
- name: Build
33+
run: dotnet build --no-restore ./src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
34+
- name: Test
35+
run: dotnet test --verbosity normal ./src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj
36+
- uses: actions/github-script@v6
37+
if: failure()
38+
with:
39+
github-token: ${{secrets.GITHUB_TOKEN}}
40+
script: |
41+
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";
42+
github.issues.create({
43+
owner: context.repo.owner,
44+
repo: context.repo.repo,
45+
title: "${{ env.build_name }} Workflow ${{ github.run_number }} Failed! ",
46+
body: body
47+
});
48+
49+
dockerBuildPush:
50+
runs-on: ubuntu-latest
51+
needs: build
52+
53+
steps:
54+
- uses: actions/checkout@v3
55+
56+
- name: Docker Login
57+
# You may pin to the exact commit or the version.
58+
# uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
59+
uses: docker/[email protected]
60+
with:
61+
# Server address of Docker registry. If not set then will default to Docker Hub
62+
registry: ${{ secrets.ACR_LOGIN_SERVER }}
63+
# Username used to log against the Docker registry
64+
username: ${{ secrets.ACR_USERNAME }}
65+
# Password or personal access token used to log against the Docker registry
66+
password: ${{ secrets.ACR_PASSWORD }}
67+
# Log out from the Docker registry at the end of a job
68+
logout: true
69+
70+
- name: Docker Build
71+
run: docker build -t $registryName/$repositoryName:$tag --build-arg build_version=$tag $dockerFolderPath
72+
73+
- name: Docker Push
74+
run: docker push $registryName/$repositoryName:$tag
75+
76+
deploy-to-dev:
77+
78+
runs-on: ubuntu-latest
79+
needs: dockerBuildPush
80+
environment:
81+
name: dev
82+
url: https://{your_prefix}-dev.azurewebsites.net/
83+
84+
steps:
85+
- name: 'Login via Azure CLI'
86+
uses: azure/[email protected]
87+
with:
88+
creds: ${{ secrets.AZURE_CREDENTIALS }}
89+
90+
- uses: azure/webapps-deploy@v2
91+
with:
92+
app-name: '{your_prefix}-dev'
93+
images: {your_registry_name}.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}
94+
95+
deploy-to-test:
96+
97+
runs-on: ubuntu-latest
98+
needs: deploy-to-dev
99+
environment:
100+
name: test
101+
url: https://{your_prefix}-test.azurewebsites.net/
102+
103+
steps:
104+
- uses: actions/checkout@v3
105+
106+
- name: 'Login via Azure CLI'
107+
uses: azure/[email protected]
108+
with:
109+
creds: ${{ secrets.AZURE_CREDENTIALS }}
110+
111+
- uses: azure/webapps-deploy@v2
112+
with:
113+
app-name: '{your_prefix}-test'
114+
images: {your_registry_name}.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}
115+
116+
deploy-to-prod:
117+
118+
runs-on: ubuntu-latest
119+
needs: deploy-to-test
120+
environment:
121+
name: prod
122+
url: https://{your_prefix}-prod.azurewebsites.net/
123+
124+
steps:
125+
- uses: actions/checkout@v3
126+
127+
- name: 'Login via Azure CLI'
128+
uses: azure/[email protected]
129+
with:
130+
creds: ${{ secrets.AZURE_CREDENTIALS }}
131+
132+
- uses: azure/webapps-deploy@v2
133+
with:
134+
app-name: '{your_prefix}-prod'
135+
images: {your_registry_name}.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}

docs/05_fix_performance_issue/0503.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ In this task, you will update the infrastructure as code Bicep script and create
4646
<details markdown="block">
4747
<summary>Expand this section to view the solution</summary>
4848

49+
This is an abbreviated solution. Read the **Description** section above for all of the steps to perform. This solution will not include tasks that you have performed already, such as creating GitHub Issues, commit messages, or pull requests.
50+
4951
- The final Bicep script is [in the solution folder]((https://github.com/microsoft/TechExcel-Accelerate-developer-productivity-with-GitHub-Copilot-and-Dev-Box/blob/main/Solution/Exercise-05/Task-3/main.bicep)). Before looking at this script, try to use GitHub Copilot to generate the changes to your existing `/src/InfrastructureAsCode/main.bicep` file. You may wish to use a prompt such as "Please add in a Basic C0 instance of Azure Cache for Redis." Then, you may wish to compare what GitHub Copilot generated.
5052

5153
</details>

0 commit comments

Comments
 (0)