From 82f9955950323c32785e24cd21549ea2127352f1 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sun, 18 Jun 2023 15:12:26 -0700 Subject: [PATCH] Do not push on PR events --- .github/workflows/BuildPublishPipeline.yml | 20 +++++++++++--------- Utilities.sln | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/BuildPublishPipeline.yml b/.github/workflows/BuildPublishPipeline.yml index 2c4c5b6..0701c39 100644 --- a/.github/workflows/BuildPublishPipeline.yml +++ b/.github/workflows/BuildPublishPipeline.yml @@ -8,6 +8,12 @@ on: branches: [ main ] workflow_dispatch: +env: + # Do not push on pull_request events + dopush: ${{ github.event_name != 'pull_request' }} + # main branch + mainbranch: ${{ !endsWith(github.ref, 'refs/heads/main') }} + jobs: build: name: 'Build and Publish Pipeline' @@ -58,9 +64,7 @@ jobs: # Publish to NuGet.org Registry # https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push - name: 'Publish to NuGet.org Registry' - # Do not push pull requests - if: ${{ github.event_name != 'pull_request' }} - # Use build platform specific path convention, relative paths do not work + if: ${{ dopush }} run: >- dotnet nuget push ${{ github.workspace }}/Publish/*.nupkg --source https://api.nuget.org/v3/index.json @@ -70,9 +74,7 @@ jobs: # Publish to GitHub NuGet Registry # https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry - name: 'Publish to GitHub NuGet Registry' - # Do not push pull requests - if: ${{ github.event_name != 'pull_request' }} - # Use build platform specific path convention, relative paths do not work + if: ${{ dopush }} run: >- dotnet nuget push ${{ github.workspace }}/Publish/*.nupkg --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json @@ -81,19 +83,19 @@ jobs: # Zip the output - name: 'Zip Output' + if: ${{ dopush }} run: 7z a -t7z ./Publish/Utilities.7z ./Publish/* # Create GitHub release # https://github.com/marketplace/actions/automatic-releases - name: 'Create GitHub Release' - # Do not push on pull requests - if: ${{ (github.event_name != 'pull_request') }} + if: ${{ dopush }} uses: marvinpinto/action-automatic-releases@latest with: repo_token: ${{ secrets.GITHUB_TOKEN }} automatic_release_tag: ${{ steps.nbgv.outputs.SemVer2 }} # Only main branch is not a pre-release - prerelease: ${{ !endsWith(github.ref, 'refs/heads/main') }} + prerelease: ${{ mainbranch }} files: | LICENSE ./Publish/Utilities.7z diff --git a/Utilities.sln b/Utilities.sln index 6989a70..23a7ece 100644 --- a/Utilities.sln +++ b/Utilities.sln @@ -32,6 +32,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub Actions", "GitHub Actions", "{6AEC3BF4-00CE-4C23-A003-82F12FCBA630}" ProjectSection(SolutionItems) = preProject .github\workflows\BuildPublishPipeline.yml = .github\workflows\BuildPublishPipeline.yml + .github\dependabot.yml = .github\dependabot.yml EndProjectSection EndProject Global