Skip to content

Commit 4df7711

Browse files
Make publish.yml safer - don't actually deploy to package managers if running on a branch
1 parent 9ce97da commit 4df7711

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ jobs:
106106
name: nodejs-package
107107
path: nodejs/*.tgz
108108
- name: Publish to npm
109+
if: github.ref == 'refs/heads/main'
109110
run: npm publish --tag ${{ github.event.inputs.dist-tag }} --access public --registry https://registry.npmjs.org
110111

111112
publish-dotnet:
@@ -130,6 +131,7 @@ jobs:
130131
name: dotnet-package
131132
path: dotnet/artifacts/*.nupkg
132133
- name: NuGet login (OIDC)
134+
if: github.ref == 'refs/heads/main'
133135
uses: NuGet/login@v1
134136
id: nuget-login
135137
with:
@@ -139,6 +141,7 @@ jobs:
139141
# are associated with individual maintainers' accounts too.
140142
user: stevesanderson
141143
- name: Publish to NuGet
144+
if: github.ref == 'refs/heads/main'
142145
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
143146

144147
publish-python:
@@ -171,6 +174,7 @@ jobs:
171174
name: python-package
172175
path: python/dist/*
173176
- name: Publish to PyPI
177+
if: github.ref == 'refs/heads/main'
174178
uses: pypa/gh-action-pypi-publish@release/v1
175179
with:
176180
packages-dir: python/dist/

0 commit comments

Comments
 (0)