From 3ad700c63e5c0eb17aaee1e13d72fb992dbfcb06 Mon Sep 17 00:00:00 2001 From: Ramazan Yilmaz Date: Thu, 8 Aug 2024 20:12:21 +0200 Subject: [PATCH 1/4] Add cleanup workflow --- .github/workflows/cleanup.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/cleanup.yml diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml new file mode 100644 index 0000000..7b31cdb --- /dev/null +++ b/.github/workflows/cleanup.yml @@ -0,0 +1,13 @@ +on: + workflow_call: + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: geekyeggo/delete-artifact@v5 + with: + name: ${{ vars.IMAGE_NAME }} + failOnError: false From 24abceeb63b3b2ad91a74097cb3a96cfaa1084d6 Mon Sep 17 00:00:00 2001 From: Ramazan Yilmaz Date: Thu, 8 Aug 2024 20:17:54 +0200 Subject: [PATCH 2/4] Use cleanup for release and manual release --- ...uild-test-release.yml => build-test-release-cleanup.yml} | 6 ++++++ ...manually.yml => build-test-release-cleanup_manually.yml} | 5 +++++ DEVELOPMENT.md | 4 ++-- README.md | 3 +-- 4 files changed, 14 insertions(+), 4 deletions(-) rename .github/workflows/{build-test-release.yml => build-test-release-cleanup.yml} (85%) rename .github/workflows/{build-test-release_manually.yml => build-test-release-cleanup_manually.yml} (83%) diff --git a/.github/workflows/build-test-release.yml b/.github/workflows/build-test-release-cleanup.yml similarity index 85% rename from .github/workflows/build-test-release.yml rename to .github/workflows/build-test-release-cleanup.yml index d24ac9f..1d85d80 100644 --- a/.github/workflows/build-test-release.yml +++ b/.github/workflows/build-test-release-cleanup.yml @@ -30,3 +30,9 @@ jobs: secrets: inherit with: image_version: ${{ needs.test.outputs.image_version }} + cleanup: + if: always() + needs: release + uses: ./.github/workflows/cleanup.yml + secrets: inherit + diff --git a/.github/workflows/build-test-release_manually.yml b/.github/workflows/build-test-release-cleanup_manually.yml similarity index 83% rename from .github/workflows/build-test-release_manually.yml rename to .github/workflows/build-test-release-cleanup_manually.yml index b12e838..4d2bc79 100644 --- a/.github/workflows/build-test-release_manually.yml +++ b/.github/workflows/build-test-release-cleanup_manually.yml @@ -25,3 +25,8 @@ jobs: secrets: inherit with: image_version: ${{ inputs.image_version }} + cleanup: + if: always() + needs: release + uses: ./.github/workflows/cleanup.yml + secrets: inherit diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 5652b5f..0c97962 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -32,8 +32,8 @@ The workflows are described in the following table: | Workflow | File name | Trigger | Description | |----------------|----------------------------------------------------------------------------------------|------------------------------------------------------|----------------------------------------------------------------------------------------| | ci | [build-test.yml](./.github/workflows/build-test.yml) | All branches and pull requests to develop and master | Builds and tests the software | -| release | [build-test-release.yml](./.github/workflows/build-test-release.yml) | Commits to develop, master and release/* branches | Builds and tests software and pushes it to the Docker Hub if the tests were successful | -| manual_release | [build-test-release_manually.yml](./.github/workflows/build-test-release_manually.yml) | Manual, can be triggeret on any branch | Builds and tests software and pushes it to the Docker Hub if the tests were successful | +| release | [build-test-release-cleanup.yml](./.github/workflows/build-test-release-cleanup.yml) | Commits to develop, master and release/* branches | Builds and tests software and pushes it to the Docker Hub if the tests were successful | +| manual_release | [build-test-release-cleanup_manually.yml](./.github/workflows/build-test-release-cleanup_manually.yml) | Manual, can be triggeret on any branch | Builds and tests software and pushes it to the Docker Hub if the tests were successful | | update-readme | [update-dockerhub-readme.yml](./.github/workflows/update-dockerhub-readme.yml) | Commits on master branch | Updates ReadMe on docker hub | Version names are automatically set by the reusable workflow `set_version`, based on branch names. See in the file [set_version.yml](./.github/workflows/set_version.yml) diff --git a/README.md b/README.md index f3e92b7..e0dbe81 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,9 @@ [![MIT Licensed](https://img.shields.io/github/license/ramo-y/BulkRename.svg)](https://github.com/Ramo-Y/BulkRename/blob/master/LICENSE) [![Activity](https://img.shields.io/github/commit-activity/m/Ramo-Y/BulkRename)](https://github.com/Ramo-Y/BulkRename/pulse) [![ci](https://img.shields.io/github/actions/workflow/status/Ramo-Y/BulkRename/build-test.yml?label=ci)](https://github.com/Ramo-Y/BulkRename/actions/workflows/build-test.yml) -[![release](https://img.shields.io/github/actions/workflow/status/Ramo-Y/BulkRename/build-test-release.yml?label=release)](https://github.com/Ramo-Y/BulkRename/actions/workflows/build-test-release.yml) +[![release](https://img.shields.io/github/actions/workflow/status/Ramo-Y/BulkRename/build-test-release-cleanup.yml?label=release)](https://github.com/Ramo-Y/BulkRename/actions/workflows/build-test-release-cleanup.yml) [![GitHub contributors](https://img.shields.io/github/all-contributors/Ramo-Y/BulkRename)](#contributors-) [![GitHub Sponsors](https://img.shields.io/github/sponsors/Ramo-Y)](https://github.com/sponsors/Ramo-Y) -![GitHub Downloads](https://img.shields.io/github/downloads/Ramo-Y/BulkRename/total) [![Open Issues](https://img.shields.io/github/issues/Ramo-Y/BulkRename)](https://github.com/Ramo-Y/BulkRename/issues) [![Closed Issues](https://img.shields.io/github/issues-closed/Ramo-Y/BulkRename)](https://github.com/Ramo-Y/BulkRename/issues?q=is%3Aissue+is%3Aclosed) From 5158c9d210a32dc77c928b26257799192716ca4a Mon Sep 17 00:00:00 2001 From: Ramazan Yilmaz Date: Thu, 8 Aug 2024 20:31:09 +0200 Subject: [PATCH 3/4] Use cleanup in ci pipeline --- .github/workflows/{build-test.yml => build-test-cleanup.yml} | 5 +++++ DEVELOPMENT.md | 2 +- README.md | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) rename .github/workflows/{build-test.yml => build-test-cleanup.yml} (84%) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test-cleanup.yml similarity index 84% rename from .github/workflows/build-test.yml rename to .github/workflows/build-test-cleanup.yml index 8ddf6bc..1275cd5 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test-cleanup.yml @@ -27,3 +27,8 @@ jobs: secrets: inherit with: image_version: ${{ needs.build.outputs.image_version }} + cleanup: + if: always() + needs: test + uses: ./.github/workflows/cleanup.yml + secrets: inherit diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 0c97962..29a97e2 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -31,7 +31,7 @@ The workflows are described in the following table: | Workflow | File name | Trigger | Description | |----------------|----------------------------------------------------------------------------------------|------------------------------------------------------|----------------------------------------------------------------------------------------| -| ci | [build-test.yml](./.github/workflows/build-test.yml) | All branches and pull requests to develop and master | Builds and tests the software | +| ci | [build-test-cleanup.yml](./.github/workflows/build-test-cleanup.yml) | All branches and pull requests to develop and master | Builds and tests the software | | release | [build-test-release-cleanup.yml](./.github/workflows/build-test-release-cleanup.yml) | Commits to develop, master and release/* branches | Builds and tests software and pushes it to the Docker Hub if the tests were successful | | manual_release | [build-test-release-cleanup_manually.yml](./.github/workflows/build-test-release-cleanup_manually.yml) | Manual, can be triggeret on any branch | Builds and tests software and pushes it to the Docker Hub if the tests were successful | | update-readme | [update-dockerhub-readme.yml](./.github/workflows/update-dockerhub-readme.yml) | Commits on master branch | Updates ReadMe on docker hub | diff --git a/README.md b/README.md index e0dbe81..eca3917 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Docker Pulls](https://img.shields.io/docker/pulls/ramoy/bulkrename.svg)](https://hub.docker.com/r/ramoy/bulkrename) [![MIT Licensed](https://img.shields.io/github/license/ramo-y/BulkRename.svg)](https://github.com/Ramo-Y/BulkRename/blob/master/LICENSE) [![Activity](https://img.shields.io/github/commit-activity/m/Ramo-Y/BulkRename)](https://github.com/Ramo-Y/BulkRename/pulse) -[![ci](https://img.shields.io/github/actions/workflow/status/Ramo-Y/BulkRename/build-test.yml?label=ci)](https://github.com/Ramo-Y/BulkRename/actions/workflows/build-test.yml) +[![ci](https://img.shields.io/github/actions/workflow/status/Ramo-Y/BulkRename/build-test-cleanup.yml?label=ci)](https://github.com/Ramo-Y/BulkRename/actions/workflows/build-test-cleanup.yml) [![release](https://img.shields.io/github/actions/workflow/status/Ramo-Y/BulkRename/build-test-release-cleanup.yml?label=release)](https://github.com/Ramo-Y/BulkRename/actions/workflows/build-test-release-cleanup.yml) [![GitHub contributors](https://img.shields.io/github/all-contributors/Ramo-Y/BulkRename)](#contributors-) [![GitHub Sponsors](https://img.shields.io/github/sponsors/Ramo-Y)](https://github.com/sponsors/Ramo-Y) From eca0598a28a18344fdae9ceff5c1e5f359d87d91 Mon Sep 17 00:00:00 2001 From: Ramazan Yilmaz Date: Fri, 9 Aug 2024 18:00:09 +0200 Subject: [PATCH 4/4] Check persistance mode before preparating database --- src/BulkRename/Startup.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/BulkRename/Startup.cs b/src/BulkRename/Startup.cs index 47544d4..20ba50c 100644 --- a/src/BulkRename/Startup.cs +++ b/src/BulkRename/Startup.cs @@ -60,6 +60,12 @@ private void ConfigurePersistance(IServiceCollection services) } public async Task Configure(WebApplication app) + { + ConfigureLogger(); + await PreparateDatabase(app); + } + + private void ConfigureLogger() { var seqUrl = Configuration[ConfigurationNameConstants.SEQ_URL]; @@ -78,11 +84,18 @@ public async Task Configure(WebApplication app) .WriteTo.File(path: logPath, rollingInterval: RollingInterval.Day) .WriteTo.Console().CreateLogger(); } + } - var connectionTimeOut = GetConnectionTimeOut(); - var preparationDatabase = app.Services.GetService(); - var task = preparationDatabase!.PreparatePopulation(app, connectionTimeOut); - await task; + private async Task PreparateDatabase(WebApplication app) + { + var persistanceMode = Configuration.GetValue(nameof(PersistanceMode)); + if (persistanceMode == PersistanceMode.Database) + { + var connectionTimeOut = GetConnectionTimeOut(); + var preparationDatabase = app.Services.GetService(); + var task = preparationDatabase!.PreparatePopulation(app, connectionTimeOut); + await task; + } } private void SetConnectionString()