From b5353a37986776070bd0caa9e0db4320bd45835f Mon Sep 17 00:00:00 2001 From: Antonis Kotis Date: Fri, 9 May 2025 22:33:12 +0300 Subject: [PATCH 1/2] Add Discord Message when eveyrhing was completed sucesfully --- .github/workflows/publish.yml | 47 +++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bdf41cf..37b5142 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,6 +23,8 @@ defaults: shell: pwsh jobs: + + # Create the NuGet package create_nuget: runs-on: ubuntu-latest steps: @@ -52,11 +54,26 @@ jobs: if-no-files-found: error retention-days: 7 path: ${{ env.NuGetDirectory }}/*.nupkg + + # Run tests + run_test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + # Install .NET 9.0 SDK + - name: Setup .NET 9.0 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' # Use a specific version or '9.0.x' for the latest 9.0 preview + + - name: Run Tests + run: dotnet test --configuration Release - + # Validate the NuGet package validate_nuget: runs-on: ubuntu-latest - needs: [ create_nuget ] + needs: [ create_nuget, run_test ] steps: # Install .NET 9.0 SDK @@ -82,27 +99,25 @@ jobs: run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg") continue-on-error: true # Continue on Error - - run_test: + # Inform Discord that new PR is available and needs approval for PROD + notify_discord: runs-on: ubuntu-latest + needs: [ create_nuget, run_test ] steps: - - uses: actions/checkout@v3 - - # Install .NET 9.0 SDK - - name: Setup .NET 9.0 - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '9.0.x' # Use a specific version or '9.0.x' for the latest 9.0 preview - - - name: Run Tests - run: dotnet test --configuration Release - + - name: Notify Discord + uses: rjstone/discord-webhook-notify@v1.0.4 + with: + severity: info + details: A new pull request is awaiting approval to initiate the creation of a NuGet package for FeatureMasterX. + webhookurl: ${{ secrets.DISCORD_WEBHOOK }} + + # Deploy to NuGet.org deploy: # Publish only when creating a GitHub Release # https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository # You can update this logic if you want to manage releases differently - if: github.event_name == 'release' + if: github.event_name == 'Release' runs-on: ubuntu-latest needs: [ validate_nuget, run_test ] environment: From b110f778c42cc4084edffefc606a0541f15cb99f Mon Sep 17 00:00:00 2001 From: Antonis Kotis Date: Fri, 9 May 2025 22:38:08 +0300 Subject: [PATCH 2/2] Changes to work as expected --- .github/workflows/publish.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 37b5142..0503a7b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -101,8 +101,9 @@ jobs: # Inform Discord that new PR is available and needs approval for PROD notify_discord: + if: github.event_name == 'Release' runs-on: ubuntu-latest - needs: [ create_nuget, run_test ] + needs: [ validate_nuget ] steps: - name: Notify Discord uses: rjstone/discord-webhook-notify@v1.0.4 @@ -119,7 +120,7 @@ jobs: # You can update this logic if you want to manage releases differently if: github.event_name == 'Release' runs-on: ubuntu-latest - needs: [ validate_nuget, run_test ] + needs: [ validate_nuget ] environment: name: Production # Your environment name url: ${{ steps.set-url.outputs.url }} # optional