diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..2b7542a4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI + +env: + DOTNET_VERSION: '8.0' # set this to the .NET Core version to use + +on: + push: + branches: [ "main" ] + +jobs: + build: + name: CI + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Build with dotnet + run: dotnet build --configuration Release + + - name: dotnet test + run: dotnet test --configuration Release --no-build + + - name: dotnet publish + run: dotnet publish src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj --configuration Release -o artifacts + + - uses: actions/upload-artifact@v4 + with: + name: dometrain-artifact + path: artifacts/ diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml new file mode 100644 index 00000000..780164a7 --- /dev/null +++ b/.github/workflows/cron.yml @@ -0,0 +1,17 @@ +name: Run every 1 hour + +env: + DOTNET_VERSION: '8.0' # set this to the .NET Core version to use + +on: + schedule: + - cron: "0 * * * *" + +jobs: + cron: + name: Run every 1 hour + runs-on: ubuntu-latest + + steps: + - name: Hello world + run: echo "Hello World" diff --git a/.github/workflows/pr-verify.yml b/.github/workflows/pr-verify.yml new file mode 100644 index 00000000..804aedcf --- /dev/null +++ b/.github/workflows/pr-verify.yml @@ -0,0 +1,30 @@ +name: PR Verify + +env: + DOTNET_VERSION: '8.0' # set this to the .NET Core version to use + +on: + pull_request: + branches: [ "main" ] + +jobs: + build: + name: PR Verify + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - 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 diff --git a/.github/workflows/secrets.yml b/.github/workflows/secrets.yml new file mode 100644 index 00000000..6e3fa543 --- /dev/null +++ b/.github/workflows/secrets.yml @@ -0,0 +1,18 @@ +name: Secrets workflow + +env: + DOTNET_VERSION: '8.0' # set this to the .NET Core version to use + API_CSPROJ_PATH: "./src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj" + +on: + pull_request: + branches: [ "main" ] + +jobs: + secrets: + name: Secrets Demo + runs-on: ubuntu-latest + + steps: + - name: echo environment variable + run: echo "The value of SECRET_API_KEY is $${{secrets.SECRET_API_KEY}}" diff --git a/src/GitHubActionsDotNet.Api/Models/WeatherForecast.cs b/src/GitHubActionsDotNet.Api/Models/WeatherForecast.cs index 786b4a10..baad2092 100644 --- a/src/GitHubActionsDotNet.Api/Models/WeatherForecast.cs +++ b/src/GitHubActionsDotNet.Api/Models/WeatherForecast.cs @@ -9,4 +9,7 @@ public record WeatherForecast public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); public string? Summary { get; init; } + + public string? Observatory { get; init; } + }