Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Further improvements with git commit version (add support for docker image)
support11a8f39b9745
diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.ymlindex c66ab796c..ea734a2e5 100644--- a/.github/workflows/docker-image.yml+++ b/.github/workflows/docker-image.yml@@ -1,5 +1,8 @@name: Docker Image CI+env:+ TAG: 'latest'+on:push:branches: [ "master" ]@@ -16,25 +19,20 @@ jobs:steps:- name: Checkoutuses: actions/checkout@v2- - id: Commit- name: Commit-tag- uses: pr-mpt/actions-commit-hash@v2- name: Buildxid: buildxuses: docker/setup-buildx-action@v1-- name: Login to Docker Hubuses: docker/login-action@v2with:username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_PASS }}-- name: Build and pushuses: docker/build-push-action@v2with:context: .build-args: |- GIT_COMMIT=${{ steps.commit.outputs.long }}- GIT_BRANCH=master+ GIT_COMMIT=${{ github.sha }}+ GIT_BRANCH=${{ github.ref_name }}push: true- tags: grandnode/grandnode2:latest\ No newline at end of file+ tags: grandnode/grandnode2:${{ env.TAG }}\ No newline at end of filediff --git a/Dockerfile b/Dockerfileindex 5cee47667..ea4a4fee9 100644--- a/Dockerfile+++ b/Dockerfile@@ -25,8 +25,14 @@ RUN dotnet build /app/Plugins/Widgets.FacebookPixel -c Release -p:SourceRevisionRUN dotnet build /app/Plugins/Widgets.GoogleAnalytics -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCHRUN dotnet build /app/Plugins/Widgets.Slider -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH-# build Web-RUN dotnet publish /app/Web/Grand.Web -c Release -o ./build/release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH+# restore+RUN dotnet restore /app/Web/Grand.Web/Grand.Web.csproj++#build+RUN dotnet build /app/Web/Grand.Web/Grand.Web.csproj --no-restore -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH++# publish Web+RUN dotnet publish /app/Web/Grand.Web --no-restore -c Release -o ./build/release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH# Build runtime imageFROM mcr.microsoft.com/dotnet/aspnet:6.0diff --git a/src/Build/Grand.Common.props b/src/Build/Grand.Common.propsindex b124f24ba..23c183798 100644--- a/src/Build/Grand.Common.props+++ b/src/Build/Grand.Common.props@@ -18,17 +18,20 @@<Using Include="System.Threading"/><Using Include="System.Threading.Tasks"/></ItemGroup>- <Target Name="SetSourceRevisionId" BeforeTargets="InitializeSourceControlInformation">+ <Target Name="SetSourceRevisionId" BeforeTargets="InitializeSourceControlInformation" Condition="'$(SourceRevisionId)'==''"><Exec Command="git describe --long --always --exclude=* --abbrev=8" ConsoleToMSBuild="True" IgnoreExitCode="True"><Output PropertyName="SourceRevisionId" TaskParameter="ConsoleOutput" /></Exec></Target>- <Target Name="SetRepositoryBranch" BeforeTargets="InitializeSourceControlInformation">+ <Target Name="SetRepositoryBranch" BeforeTargets="InitializeSourceControlInformation" Condition="'$(GitBranch)'==''"><Exec Command="git rev-parse --abbrev-ref HEAD" ConsoleToMSBuild="True" IgnoreExitCode="True">- <Output PropertyName="GitBranch" TaskParameter="ConsoleOutput" />+ <Output PropertyName="branch" TaskParameter="ConsoleOutput" /></Exec><ItemGroup>- <AssemblyMetadata Include="BranchName" Value="$(GitBranch)" />+ <AssemblyMetadata Include="BranchName" Value="$(branch)" /></ItemGroup></Target>+ <ItemGroup Condition="'$(GitBranch)'!=''">+ <AssemblyMetadata Include="GitBranch" Value="$(GitBranch)" />+ </ItemGroup></Project>diff --git a/src/Core/Grand.Infrastructure/GrandVersion.cs b/src/Core/Grand.Infrastructure/GrandVersion.csindex 36ca00a6d..79d94f58a 100644--- a/src/Core/Grand.Infrastructure/GrandVersion.cs+++ b/src/Core/Grand.Infrastructure/GrandVersion.cs@@ -68,7 +68,7 @@ namespace Grand.Infrastructurevar appAssembly = typeof(GrandVersion).Assembly;var infoBranchAttr = appAssembly.GetCustomAttributes(typeof(AssemblyMetadataAttribute))- .FirstOrDefault(x => ((AssemblyMetadataAttribute)x).Key == "BranchName");+ .FirstOrDefault(x => ((AssemblyMetadataAttribute)x).Key == "GitBranch");_gitBranch = infoBranchAttr != null ? ((AssemblyMetadataAttribute)infoBranchAttr).Value : "UNKNOWN";return _gitBranch;}