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
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on:
push:
branches: [ "main" ]

permissions:
id-token: write
contents: read

jobs:
build:
name: ci
runs-on: ubuntu-latest

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

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0

# Did not include a dotnet build step because imn the test, we are going to build anyway. We did not use the "--no-build" flag.
# Also, We have the test runiing imn another workflo, but this is so critical that we included this here again even if someone
# bypasses the ruleset, we will have these test here anyway.

- name: dotnet test
run: dotnet test --configuration Release

# I did not include a step for dotnet format because we already took care of that indirectly for this repo. We enforced rules to
# have the incomming branch to be updated with the branch "main" changes. Also, as status checks are required and we have other
# workflow thayt takes care of that, there is no need to include formatting here.

# Of course, the recommendation is to have ALL verifications in the CI workflow

- name: dotnet publish
run: dotnet publish src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj --configuration Release -o artifacts-release-folder

- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: dometrain-artifact
path: artifacts-release-folder/

deploy-dev:
name: Deploy Dev
needs: build # We make sure this job waits for the "build" job
uses: fgavilanm/github-actions-reusable/.github/workflows/step-deploy-web-app-azure.yml@main #Instead of ./.github/workflows/deploy-to-azure.yml
with:
env: prod
secrets: inherit


deploy-prod:
name: Deploy Pro
needs: deploy-dev
uses: ./.github/workflows/deploy-to-azure.yml
with:
env: prod
secrets: inherit



40 changes: 40 additions & 0 deletions .github/workflows/deploy-to-azure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy to azure

on:
workflow_call:
inputs:
env:
required: true
type: string
secrets:
AZURE_CLIENT_ID:
required: true
AZURE_TENANT_ID:
required: true
AZURE_SUBSCRIPTION_ID:
required: true
jobs:
deploy:
name: Deploy ${{ inputs.env }}
runs-on: ubuntu-latest
environment: ${{ inputs.env }}

steps:
- name: download artifact
uses: actions/download-artifact@v4
with:
name: dometrain-artifact
path: artifacts/

- name: Azure login
uses: azure/login@v2

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow

Unpinned 3rd party Action 'Deploy to azure' step [Uses Step](1) uses 'azure/login' with ref 'v2', not a pinned commit hash
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: 'Deploy to Azure App Service Name'
uses: azure/webapps-deploy@v2

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow

Unpinned 3rd party Action 'Deploy to azure' step [Uses Step](1) uses 'azure/webapps-deploy' with ref 'v2', not a pinned commit hash
with:
app-name: app-dometrain-github-actions-fgavilan-${{ inputs.env }}
package: artifacts/
Comment on lines +18 to +40

Check warning

Code scanning / CodeQL

Workflow does not contain permissions

Actions Job or Workflow does not set permissions
28 changes: 28 additions & 0 deletions .github/workflows/pr-verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: PR Verify

on:
pull_request:
branches: [ "main" ]

jobs:
build:
name: PR Verify
runs-on: ubuntu-latest

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

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0

- name: Build with dotnet
run: dotnet build --configuration Release

- name: dotnet test
run: dotnet test --configuration Release --no-build

- name: dotnet format
run: dotnet format -v detailed --verify-no-changes
Comment on lines +9 to +28

Check warning

Code scanning / CodeQL

Workflow does not contain permissions

Actions Job or Workflow does not set permissions
20 changes: 20 additions & 0 deletions .github/workflows/variables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Print Variable Values

on:
workflow_dispatch:

env:
SOME_VALUE: Francisco

jobs:
build:
name: Print
runs-on: ubuntu-latest

steps:
- name: Print using runner's shell specific syntax
run: echo "the value of SOME_VALUE is $SOME_VALUE"

- name: Print using Context
run: echo "Again, the value of SOME_VALUE is ${{env.SOME_VALUE}}".

Comment on lines +11 to +20

Check warning

Code scanning / CodeQL

Workflow does not contain permissions

Actions Job or Workflow does not set permissions
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.0",
"version": "9.0.0",
"rollForward": "latestMinor",
"allowPrerelease": false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public void TemperatureFShouldReturnCorrectValueBasedOnTemperatureC()
};

weatherForecast.TemperatureF.Should().Be(32);
weatherForecast.TemperatureF.Should().Be(32);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public class WeatherForecastController : ControllerBase
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}).ToArray();
}

2 changes: 1 addition & 1 deletion src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down