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
732 changes: 323 additions & 409 deletions .editorconfig

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Cron job to run every 5 minutes
# cron jobs like do security scans after a specified period of time
on:
schedule:
- cron: '*/5 * * * *'

jobs:
cron:
name: Run every 5 minutes
runs-on: ubuntu-latest

steps:
- name: Say Hello World
run: echo "hello world"
44 changes: 44 additions & 0 deletions .github/workflows/pr-verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PR Verify

on:
pull_request:
# Trigger on PRs targeting develop and main
branches: [ "develop", "main" ]

jobs:
build:
name: PR Verify
runs-on: ubuntu-latest
# Give the job explicit write permissions so it can push a commit
permissions:
contents: write

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0

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

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

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



- name: Run formatter
run: dotnet format

- name: Commit formatted changes and push
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: Apply automatic dotnet format changes"

commit_author: 'github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>'

78 changes: 78 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Create GitHub Release

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Fetch full history with tags, necessary for git log/describe
fetch-depth: 0

- name: Get previous tag
id: previoustag
run: |
# Finds the latest tag that IS NOT the current tag being pushed.
# The "|| true" ensures the workflow doesn't fail if this is the very first tag.
prev_tag=$(git describe --tags --abbrev=0 --exclude='${{ github.ref_name }}' || true)
# Only output if a previous tag was found
if [ -n "$prev_tag" ]; then
echo "previous_tag=${prev_tag}" >> $GITHUB_OUTPUT
fi
echo "Previous Tag Found: ${prev_tag}"

if [ -n "$prev_tag" ]; then
echo "previous_tag=$prev_tag" >> $GITHUB_OUTPUT
echo "Previous tag: $prev_tag"
else
echo "No previous tag found"
fi

- name: Generate changelog
id: changelog
shell: bash
run: |
prev="${{ steps.previoustag.outputs.previous_tag }}"
tag="${GITHUB_REF_NAME}"

# Determine the commit range for the changelog
if [ -n "$prev" ]; then
# Log from the previous tag (exclusive) up to the current tag (inclusive)
log_range="${prev}..${tag}"
changelog_title="## What is in this release ${tag}"
else
# If no previous tag, log all commits up to the current tag
log_range="${tag}"
changelog_title="## Initial Release ${tag}"
fi

# Generate changelog with subject and short hash
# Using || true to avoid failure if no commits are found in the range (unlikely with a new tag)
changelog=$(git log "${log_range}" --pretty=format:"- %s (%h)" || true)

# Use EOD (End Of Delimiter) for multi-line output
{
echo "changelog<<EOD"
echo "${changelog_title}"
echo ""
echo "$changelog"
echo "EOD"
} >> "$GITHUB_OUTPUT"

- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace GitHubActionsDotNet.Api.Tests;
using FluentAssertions;

using GitHubActionsDotNet.Api.Models;

public class WeatherForecastTests
Expand All @@ -14,4 +15,5 @@ public void TemperatureFShouldReturnCorrectValueBasedOnTemperatureC()

weatherForecast.TemperatureF.Should().Be(32);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace GitHubActionsDotNet.Api.Controllers;
using GitHubActionsDotNet.Api.Models;

using Microsoft.AspNetCore.Mvc;

[ApiController]
Expand Down Expand Up @@ -28,4 +29,4 @@ public class WeatherForecastController : ControllerBase
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
2 changes: 1 addition & 1 deletion src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/GitHubActionsDotNet.Api/Models/WeatherForecast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ public record WeatherForecast
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

public string? Summary { get; init; }
}
}
3 changes: 2 additions & 1 deletion src/GitHubActionsDotNet.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
// No services to add yet to the program file

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
Expand All @@ -22,4 +23,4 @@

app.MapControllers();

app.Run();
app.Run();
4 changes: 2 additions & 2 deletions src/GitHubActionsDotNet.Api/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
1 change: 1 addition & 0 deletions src/GitHubActionsDotNet.Api/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
},
"AllowedHosts": "*"
}