mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-04-13 12:15:46 +08:00
Merge pull request #123 from meysamhadeli/ci/add-new-ci-cd-config
ci/add new ci cd config
This commit is contained in:
commit
4435c8535f
21
.github/release-drafter.yml
vendored
21
.github/release-drafter.yml
vendored
@ -8,12 +8,11 @@
|
||||
# This release drafter follows the conventions from https://keepachangelog.com, https://common-changelog.org/
|
||||
# https://www.conventionalcommits.org
|
||||
|
||||
name-template: 'v$RESOLVED_VERSION'
|
||||
tag-template: 'v$RESOLVED_VERSION'
|
||||
|
||||
template: |
|
||||
## What Changed 👀
|
||||
$CHANGES
|
||||
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
|
||||
|
||||
categories:
|
||||
- title: 🚀 Features
|
||||
labels:
|
||||
@ -27,7 +26,7 @@ categories:
|
||||
- test
|
||||
- title: 👷 CI
|
||||
labels:
|
||||
- ci
|
||||
- ci
|
||||
- title: ♻️ Changes
|
||||
labels:
|
||||
- changed
|
||||
@ -66,31 +65,31 @@ autolabeler:
|
||||
- '/(security)\/.*/'
|
||||
- label: 'refactor'
|
||||
branch:
|
||||
- '/(refactor)\/.*/'
|
||||
- '/(refactor)\/.*/'
|
||||
- label: 'docs'
|
||||
branch:
|
||||
- '/(docs)\/.*/'
|
||||
- label: 'ci'
|
||||
branch:
|
||||
- '/(ci)\/.*/'
|
||||
- '/(ci)\/.*/'
|
||||
- label: 'test'
|
||||
branch:
|
||||
- '/(test)\/.*/'
|
||||
- '/(test)\/.*/'
|
||||
- label: 'bug'
|
||||
branch:
|
||||
- '/(fix)\/.*/'
|
||||
- '/(fix)\/.*/'
|
||||
- label: 'feature'
|
||||
branch:
|
||||
- '/(feat)\/.*/'
|
||||
- label: 'minor'
|
||||
branch:
|
||||
- '/(feat)\/.*/'
|
||||
- '/(feat)\/.*/'
|
||||
- label: 'patch'
|
||||
branch:
|
||||
- '/(fix)\/.*/'
|
||||
- '/(fix)\/.*/'
|
||||
body:
|
||||
- '/JIRA-[0-9]{1,4}/'
|
||||
|
||||
|
||||
change-template: '- $TITLE (#$NUMBER)'
|
||||
exclude-contributors:
|
||||
- 'meysamhadeli'
|
||||
|
||||
59
.github/workflows/build-publish-docker.yml
vendored
Normal file
59
.github/workflows/build-publish-docker.yml
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
name: build-publish-docker
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ develop ]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
|
||||
build-and-push-docker-image:
|
||||
name: Build and Publish Docker image to DockerHub
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
|
||||
- name: Semantic Release Version
|
||||
id: semantic-version
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# because of using none default (conventionalcommits) `preset` for `semantic-release`, we should add dependency `conventional-changelog-conventionalcommits`
|
||||
# using dry-run here for preventing publish release note and just calculate version
|
||||
run: npx -p @semantic-release/git -p @semantic-release/changelog -p @semantic-release/exec semantic-release --dry-run
|
||||
|
||||
- name: Semantic Release Versions Outputs
|
||||
run: |
|
||||
echo ${{ steps.semantic-version.outputs.semantic_nextRelease_version }}
|
||||
echo ${{ steps.semantic-version.outputs.semantic_nextRelease_channel }}
|
||||
echo ${{ steps.semantic-version.outputs.semantic_nextRelease_gitTag }}
|
||||
echo ${{ steps.semantic-version.outputs.semantic_lastRelease_version }}
|
||||
echo ${{ steps.semantic-version.outputs.semantic_lastRelease_channel }}
|
||||
echo ${{ steps.semantic-version.outputs.semantic_lastRelease_gitTag }}
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Build image
|
||||
run: |
|
||||
docker build -t meysamh66/booking-microservices-flight:latest -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" .
|
||||
docker build -t meysamh66/booking-microservices-identity:latest -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" .
|
||||
docker build -t meysamh66/booking-microservices-passenger:latest -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" .
|
||||
docker build -t meysamh66/booking-microservices-booking:latest -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" .
|
||||
|
||||
- name: Publish image
|
||||
run: |
|
||||
docker push meysamh66/booking-microservices-flight:latest
|
||||
docker push meysamh66/booking-microservices-identity:latest
|
||||
docker push meysamh66/booking-microservices-passenger:latest
|
||||
docker push meysamh66/booking-microservices-booking:latest
|
||||
|
||||
40
.github/workflows/dotnet.yml
vendored
40
.github/workflows/dotnet.yml
vendored
@ -2,9 +2,9 @@ name: Build-Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" , "develop"]
|
||||
branches: [ "main" , "develop" ]
|
||||
paths-ignore:
|
||||
- "README.md"
|
||||
- "README.md"
|
||||
pull_request:
|
||||
branches: [ "main" , "develop" ]
|
||||
|
||||
@ -14,15 +14,29 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v2
|
||||
with:
|
||||
dotnet-version: 7.0.x
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore
|
||||
- name: Build
|
||||
run: dotnet build -c Release --no-restore
|
||||
- name: Test
|
||||
run: dotnet test -c Release --no-restore
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v2
|
||||
with:
|
||||
dotnet-version: 7.0.x
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
|
||||
- name: Cache NuGet Packages
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
key: ${{ runner.os }}-dotnet-nuget
|
||||
path: ~/.nuget/packages
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore
|
||||
|
||||
- name: Build
|
||||
run: dotnet build -c Release --no-restore
|
||||
|
||||
- name: Test
|
||||
run: dotnet test -c Release --no-restore
|
||||
|
||||
|
||||
@ -12,9 +12,17 @@ using Exception = System.Exception;
|
||||
|
||||
public class PersistMessageDbContext : DbContext, IPersistMessageDbContext
|
||||
{
|
||||
private readonly Lazy<ILogger<PersistMessageDbContext>> _logger;
|
||||
|
||||
public PersistMessageDbContext(DbContextOptions<PersistMessageDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
_logger = new Lazy<ILogger<PersistMessageDbContext>>(() =>
|
||||
{
|
||||
var factory = LoggerFactory.Create(b => b.AddConsole());
|
||||
var logger = factory.CreateLogger<PersistMessageDbContext>();
|
||||
return logger;
|
||||
});
|
||||
}
|
||||
|
||||
public DbSet<PersistMessage> PersistMessages => Set<PersistMessage>();
|
||||
@ -37,10 +45,7 @@ public class PersistMessageDbContext : DbContext, IPersistMessageDbContext
|
||||
{
|
||||
if (exception != null)
|
||||
{
|
||||
var factory = LoggerFactory.Create(b => b.AddConsole());
|
||||
var logger = factory.CreateLogger<PersistMessageDbContext>();
|
||||
|
||||
logger.LogError(exception,
|
||||
_logger.Value.LogError(exception,
|
||||
"Request failed with {StatusCode}. Waiting {TimeSpan} before next retry. Retry attempt {RetryCount}.",
|
||||
HttpStatusCode.Conflict,
|
||||
timeSpan,
|
||||
@ -55,12 +60,22 @@ public class PersistMessageDbContext : DbContext, IPersistMessageDbContext
|
||||
{
|
||||
foreach (var entry in ex.Entries)
|
||||
{
|
||||
var currentEntity = entry.Entity; // we can use it for specific merging
|
||||
var databaseValues = await entry.GetDatabaseValuesAsync(cancellationToken);
|
||||
var currentValue = entry.Entity; // we can use it for specific merging
|
||||
var databaseValue = await entry.GetDatabaseValuesAsync(cancellationToken);
|
||||
|
||||
if (databaseValues != null)
|
||||
_logger.Value.LogInformation(
|
||||
"Entry to entity with type: {Type}, database-value: {DatabaseValue} and current-value: {CurrentValue}",
|
||||
entry.GetType().Name,
|
||||
databaseValue,
|
||||
currentValue);
|
||||
|
||||
if (databaseValue != null)
|
||||
{
|
||||
entry.OriginalValues.SetValues(databaseValues);
|
||||
entry.OriginalValues.SetValues(databaseValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.OriginalValues.SetValues(currentValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user