-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Haik
committed
Oct 14, 2023
1 parent
c0e8e6c
commit b904110
Showing
3 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters