Skip to content

Commit

Permalink
github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Haik committed Oct 14, 2023
1 parent c0e8e6c commit b904110
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 5 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy NuGet Package

env:
PROJECT_PATH: './StartupEnvironmentCheck/StartupEnvironmentCheck.csproj'
OUTPUT_DIR: 'nupkgs'
NUGET_SOURCE: 'https://api.nuget.org/v3/index.json'
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [ '7.x.x' ]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Build
run: dotnet build ${{ env.PROJECT_PATH }}

- name: Test
run: dotnet test ${{ env.PROJECT_PATH }} --collect:"XPlat Code Coverage"

- name: Pack
run: dotnet pack ${{ env.PROJECT_PATH }} --output ${{ env.OUTPUT_DIR }}

- name: Publish
run: dotnet nuget push ${{ env.OUTPUT_DIR }}/*.nupkg -k ${{ env.NUGET_API_KEY }} -s ${{ env.NUGET_SOURCE }}
63 changes: 63 additions & 0 deletions StartupEnvironmentCheck/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Pandatech.StartupEnvironmentCheck

`Pandatech.StartupEnvironmentCheck` is a lightweight library designed to validate required environment variables at
application startup. It helps ensure that essential configurations are in place, preventing unexpected behaviors or
failures due to missing environment variables.

## Installation

You can install `Pandatech.StartupEnvironmentCheck` via NuGet Package Manager or by using the following command in your
Package Manager Console:

```powershell
Install-Package Pandatech.StartupEnvironmentCheck
```

## Usage

### Validating Environment Variables

You can use the `EnvironmentVariableValidator.ValidateEnvironmentVariables` method to validate required environment
variables. Here's an example:

```csharp
using StartupEnvironmentCheck;

public class Program
{
public static void Main(string[] args)
{
var requiredEnvVars = new List<string> { "DB_CONNECTION_STRING", "API_KEY" };
EnvironmentVariableValidator.ValidateEnvironmentVariables(requiredEnvVars);

// Continue with the rest of the application startup
}
}
```

### Handling Missing Variables

If any required environment variables are missing, a `MissingEnvironmentVariablesException` will be thrown. This
exception includes a detailed message listing the missing variables.

You can catch this exception to log the error or take other appropriate actions:

```csharp
try
{
EnvironmentVariableValidator.ValidateEnvironmentVariables(requiredEnvVars);
}
catch (MissingEnvironmentVariablesException ex)
{
// Log the error or take other actions
}
```

## Contributing

For support, issues, or contributions, please refer to the project's GitHub repository or contact the maintainers.

## License

This project is licensed under the MIT License.

15 changes: 10 additions & 5 deletions StartupEnvironmentCheck/StartupEnvironmentCheck.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@
<Title>Pandatech Startup Environment Check</Title>
<Description>Pandatech.StartupEnvironmentCheck is a library designed to validate essential environment variables during application startup. By checking required configurations, it prevents unexpected behaviors and ensures smooth initialization. Easily integrate this check into your .NET applications to enhance robustness and maintainability.</Description>
<PackageIcon>pandatech.png</PackageIcon>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<PackageTags>EnvironmentVariables, Configuration, Startup, Validation, Pandatech, DotNet, ApplicationInitialization</PackageTags>
<RepositoryUrl>https://github.com/PandaTechAM/be-lib-startup-environment-check.git</RepositoryUrl>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<PackageReleaseNotes>Exception message refactored to become more visible and readable.</PackageReleaseNotes>
</PropertyGroup>


<ItemGroup>
<None Update="pandatech.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Update="pandatech.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Update="Readme.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

</Project>

0 comments on commit b904110

Please sign in to comment.