Skip to content

Commit 3cb45f8

Browse files
Skip GitHub Packages publish for fork PRs (#363)
* Fix: Exclude fork PRs from GitHub Packages publishing - Updated condition to check if PR is from same repository - Added explanatory comments about security restrictions - Fork PRs will skip publish step but still get build artifacts - Update the permissions to allow pushing check results Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Jason Naylor <jason_naylor@sil.org>
1 parent 640bb4c commit 3cb45f8

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

.github/workflows/ci-cd.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
tags: [ 'v[0-9]+*' ]
1111

1212
permissions:
13+
checks: write
1314
contents: read
1415
packages: write
1516

@@ -91,8 +92,11 @@ jobs:
9192
run: dotnet nuget push artifacts/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.SILLSDEV_PUBLISH_NUGET_ORG}} --skip-duplicate
9293
if: github.event_name == 'push' && matrix.os == 'ubuntu-22.04'
9394

95+
# Publish packages for pull requests from the same repository only.
96+
# Fork PRs cannot authenticate to GitHub Packages due to security restrictions,
97+
# but contributors can still download build artifacts from the workflow run.
9498
- name: Publish to Github packages
95-
if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-22.04'
99+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && matrix.os == 'ubuntu-22.04'
96100
run: dotnet nuget push artifacts/*.nupkg -s https://nuget.pkg.github.com/sillsdev/index.json -k ${{secrets.GITHUB_TOKEN}} --skip-duplicate
97101

98102
- name: Publish Artifacts

0 commit comments

Comments
 (0)