mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-05-03 19:41:52 +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/
|
# This release drafter follows the conventions from https://keepachangelog.com, https://common-changelog.org/
|
||||||
# https://www.conventionalcommits.org
|
# https://www.conventionalcommits.org
|
||||||
|
|
||||||
name-template: 'v$RESOLVED_VERSION'
|
|
||||||
tag-template: 'v$RESOLVED_VERSION'
|
|
||||||
template: |
|
template: |
|
||||||
## What Changed 👀
|
## What Changed 👀
|
||||||
$CHANGES
|
$CHANGES
|
||||||
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
|
|
||||||
categories:
|
categories:
|
||||||
- title: 🚀 Features
|
- title: 🚀 Features
|
||||||
labels:
|
labels:
|
||||||
@ -27,7 +26,7 @@ categories:
|
|||||||
- test
|
- test
|
||||||
- title: 👷 CI
|
- title: 👷 CI
|
||||||
labels:
|
labels:
|
||||||
- ci
|
- ci
|
||||||
- title: ♻️ Changes
|
- title: ♻️ Changes
|
||||||
labels:
|
labels:
|
||||||
- changed
|
- changed
|
||||||
@ -66,31 +65,31 @@ autolabeler:
|
|||||||
- '/(security)\/.*/'
|
- '/(security)\/.*/'
|
||||||
- label: 'refactor'
|
- label: 'refactor'
|
||||||
branch:
|
branch:
|
||||||
- '/(refactor)\/.*/'
|
- '/(refactor)\/.*/'
|
||||||
- label: 'docs'
|
- label: 'docs'
|
||||||
branch:
|
branch:
|
||||||
- '/(docs)\/.*/'
|
- '/(docs)\/.*/'
|
||||||
- label: 'ci'
|
- label: 'ci'
|
||||||
branch:
|
branch:
|
||||||
- '/(ci)\/.*/'
|
- '/(ci)\/.*/'
|
||||||
- label: 'test'
|
- label: 'test'
|
||||||
branch:
|
branch:
|
||||||
- '/(test)\/.*/'
|
- '/(test)\/.*/'
|
||||||
- label: 'bug'
|
- label: 'bug'
|
||||||
branch:
|
branch:
|
||||||
- '/(fix)\/.*/'
|
- '/(fix)\/.*/'
|
||||||
- label: 'feature'
|
- label: 'feature'
|
||||||
branch:
|
branch:
|
||||||
- '/(feat)\/.*/'
|
- '/(feat)\/.*/'
|
||||||
- label: 'minor'
|
- label: 'minor'
|
||||||
branch:
|
branch:
|
||||||
- '/(feat)\/.*/'
|
- '/(feat)\/.*/'
|
||||||
- label: 'patch'
|
- label: 'patch'
|
||||||
branch:
|
branch:
|
||||||
- '/(fix)\/.*/'
|
- '/(fix)\/.*/'
|
||||||
body:
|
body:
|
||||||
- '/JIRA-[0-9]{1,4}/'
|
- '/JIRA-[0-9]{1,4}/'
|
||||||
|
|
||||||
change-template: '- $TITLE (#$NUMBER)'
|
change-template: '- $TITLE (#$NUMBER)'
|
||||||
exclude-contributors:
|
exclude-contributors:
|
||||||
- 'meysamhadeli'
|
- '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:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" , "develop"]
|
branches: [ "main" , "develop" ]
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- "README.md"
|
- "README.md"
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" , "develop" ]
|
branches: [ "main" , "develop" ]
|
||||||
|
|
||||||
@ -14,15 +14,29 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@v2
|
uses: actions/setup-dotnet@v2
|
||||||
with:
|
with:
|
||||||
dotnet-version: 7.0.x
|
dotnet-version: 7.0.x
|
||||||
- name: Restore dependencies
|
|
||||||
run: dotnet restore
|
- name: Setup Node.js
|
||||||
- name: Build
|
uses: actions/setup-node@v2
|
||||||
run: dotnet build -c Release --no-restore
|
with:
|
||||||
- name: Test
|
node-version: 'lts/*'
|
||||||
run: dotnet test -c Release --no-restore
|
|
||||||
|
- 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
|
public class PersistMessageDbContext : DbContext, IPersistMessageDbContext
|
||||||
{
|
{
|
||||||
|
private readonly Lazy<ILogger<PersistMessageDbContext>> _logger;
|
||||||
|
|
||||||
public PersistMessageDbContext(DbContextOptions<PersistMessageDbContext> options)
|
public PersistMessageDbContext(DbContextOptions<PersistMessageDbContext> options)
|
||||||
: base(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>();
|
public DbSet<PersistMessage> PersistMessages => Set<PersistMessage>();
|
||||||
@ -37,10 +45,7 @@ public class PersistMessageDbContext : DbContext, IPersistMessageDbContext
|
|||||||
{
|
{
|
||||||
if (exception != null)
|
if (exception != null)
|
||||||
{
|
{
|
||||||
var factory = LoggerFactory.Create(b => b.AddConsole());
|
_logger.Value.LogError(exception,
|
||||||
var logger = factory.CreateLogger<PersistMessageDbContext>();
|
|
||||||
|
|
||||||
logger.LogError(exception,
|
|
||||||
"Request failed with {StatusCode}. Waiting {TimeSpan} before next retry. Retry attempt {RetryCount}.",
|
"Request failed with {StatusCode}. Waiting {TimeSpan} before next retry. Retry attempt {RetryCount}.",
|
||||||
HttpStatusCode.Conflict,
|
HttpStatusCode.Conflict,
|
||||||
timeSpan,
|
timeSpan,
|
||||||
@ -55,12 +60,22 @@ public class PersistMessageDbContext : DbContext, IPersistMessageDbContext
|
|||||||
{
|
{
|
||||||
foreach (var entry in ex.Entries)
|
foreach (var entry in ex.Entries)
|
||||||
{
|
{
|
||||||
var currentEntity = entry.Entity; // we can use it for specific merging
|
var currentValue = entry.Entity; // we can use it for specific merging
|
||||||
var databaseValues = await entry.GetDatabaseValuesAsync(cancellationToken);
|
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