Skip to content

Commit 39572e3

Browse files
Merge pull request #443 from Azure/user/vchintalapat/github-actions-test
User/vchintalapat/GitHub actions test
2 parents b800e53 + cc54675 commit 39572e3

File tree

10 files changed

+3342
-1
lines changed

10 files changed

+3342
-1
lines changed

.github/workflows/defaultLabels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ jobs:
3232
stale-pr-label: 'idle'
3333
days-before-stale: 14
3434
days-before-close: -1
35-
operations-per-run: 100
35+
operations-per-run: 100
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
2+
# More GitHub Actions for Azure: https://github.com/Azure/actions
3+
4+
name: Build and deploy to Azure App Services
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
schedule:
11+
- cron: "0 0/3 * * *"
12+
13+
jobs:
14+
build-and-deploy-dotnet-app:
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
id-token: write
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Modify the sample app
24+
run: |
25+
cp -r ./__tests__/dotnetsampleapp dotnetapp
26+
current_utc_time=$(date -u +"%Y-%m-%d %H:%M:%S %Z")
27+
sed -i "s/<<<net-place-holder>>>/$current_utc_time/g" dotnetapp/Controllers/HelloController.cs
28+
29+
echo "The placeholder has been replaced with current UTC time: $current_utc_time"
30+
31+
- name: Set up .NET Core
32+
uses: actions/setup-dotnet@v4
33+
with:
34+
dotnet-version: '8.x'
35+
36+
- name: Build with dotnet
37+
run: dotnet build --configuration Release dotnetapp/DOTNET_8_APP.csproj
38+
39+
- name: dotnet publish
40+
run: dotnet publish dotnetapp/DOTNET_8_APP.csproj -c Release -o myapp
41+
42+
- name: Upload artifact for deployment job
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: .net-app
46+
path: myapp
47+
48+
- name: Login to Azure
49+
uses: azure/login@v2
50+
with:
51+
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_DOTNETAPP1 }}
52+
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID }}
53+
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID }}
54+
55+
- name: Deploy to Azure Web App
56+
id: deploy-to-webapp
57+
uses: azure/webapps-deploy@v3
58+
with:
59+
app-name: 'lwasv2-euap-dotnet-githubactionstest'
60+
slot-name: 'Production'
61+
package: myapp
62+
63+
build-and-deploy-node-app:
64+
runs-on: ubuntu-latest
65+
66+
permissions:
67+
id-token: write
68+
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
- name: modify Node.js App
73+
run: |
74+
cp -r ./__tests__/nodesampleapp nodeapp
75+
current_utc_time=$(date -u +"%Y-%m-%d %H:%M:%S %Z")
76+
sed -i "s/<<<node-place-holder>>>/$current_utc_time/g" nodeapp/server.js
77+
78+
echo "The placeholder has been replaced with current UTC time: $current_utc_time"
79+
80+
- name: Set up Node.js version
81+
uses: actions/setup-node@v3
82+
with:
83+
node-version: '18.x'
84+
85+
- name: npm install, build, and test
86+
run: |
87+
cd nodeapp
88+
npm install
89+
npm run build --if-present
90+
npm run test --if-present
91+
92+
- name: Upload artifact for deployment job
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: node-app
96+
path: nodeapp
97+
98+
- name: Login to Azure
99+
uses: azure/login@v2
100+
with:
101+
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_NODEAPP1 }}
102+
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID }}
103+
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID }}
104+
105+
- name: 'Deploy to Azure Web App'
106+
id: deploy-to-webapp
107+
uses: azure/webapps-deploy@v3
108+
with:
109+
app-name: 'lwasv2-euap-node-githubactions'
110+
slot-name: 'Production'
111+
package: nodeapp
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace DOTNET_8_APP.Controllers
4+
{
5+
[ApiController]
6+
public class HelloController : Controller
7+
{
8+
private readonly ILogger<HelloController> _logger;
9+
private const string dummyAppSetting = "DUMMY_APPSETTING";
10+
11+
public HelloController(ILogger<HelloController> logger)
12+
{
13+
_logger = logger;
14+
}
15+
16+
[HttpGet]
17+
[Route("/")]
18+
public string Hello()
19+
{
20+
Console.WriteLine("Hello endpoint called!");
21+
return "Hello from .NET 8 App ";
22+
}
23+
24+
[HttpGet]
25+
[Route("/dummy")]
26+
public string DummyAppsetting()
27+
{
28+
Console.WriteLine("Dummy endpoint called!!");
29+
var dummyAppSettingValue = Environment.GetEnvironmentVariable(dummyAppSetting);
30+
if (dummyAppSettingValue != null) { return dummyAppSettingValue; }
31+
return "Appsetting not found!";
32+
}
33+
34+
[HttpGet]
35+
[Route("/placeholder")]
36+
public string PlaceHolder()
37+
{
38+
Console.WriteLine("Placeholder endpoint called!!");
39+
return "<<<net-place-holder>>>";
40+
}
41+
}
42+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<InvariantGlobalization>true</InvariantGlobalization>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0-preview.7.23375.9" />
12+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var builder = WebApplication.CreateBuilder(args);
2+
3+
// Add services to the container.
4+
5+
builder.Services.AddControllers();
6+
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
7+
builder.Services.AddEndpointsApiExplorer();
8+
builder.Services.AddSwaggerGen();
9+
10+
var app = builder.Build();
11+
12+
// Configure the HTTP request pipeline.
13+
if (app.Environment.IsDevelopment())
14+
{
15+
app.UseSwagger();
16+
app.UseSwaggerUI();
17+
}
18+
19+
app.UseAuthorization();
20+
21+
app.MapControllers();
22+
23+
app.Run();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}

0 commit comments

Comments
 (0)