Skip to content

Commit

Permalink
Do not push on PR events
Browse files Browse the repository at this point in the history
  • Loading branch information
ptr727 committed Jun 18, 2023
1 parent e5821f1 commit 82f9955
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/BuildPublishPipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions Utilities.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 82f9955

Please sign in to comment.