Skip to content

Prevent Deploy Workflow from Running in Forks #1981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 16, 2025

Conversation

Bashamega
Copy link
Contributor

Hello!

I’ve added a safeguard to ensure that the NPM deploy action only runs in the main repository.

🛠️ What was happening:

The workflow was being triggered daily in my fork, which obviously failed because the NPM token (NODE_AUTH_TOKEN) isn’t available in forks.

✅ What I changed:

Added the following condition to the job:

if: github.repository == 'your-username/your-repo-name'

This ensures that the deploy job only runs in the main repo, and not in forks. If someone removes that line, the job might start triggering (and failing) in forks again — so it's important to keep it!

@jakebailey
Copy link
Member

Seems fine but you'd probably be better off disabling GHA on your forks.

@jakebailey jakebailey merged commit a729227 into microsoft:main Apr 16, 2025
5 checks passed
@Bashamega
Copy link
Contributor Author

Bashamega commented Apr 16, 2025

Seems fine but you'd probably be better off disabling GHA on your forks.

I think this way is easier for contributors—and I also like that some workflows, like the build, run on my fork. Anyway, thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants