Replies: 2 comments
-
|
GitHub intentionally does not expose repository secrets to workflows triggered from forked repositories. There is no safe way to directly pass secrets to fork-based The 100% correct and secure pattern is to separate untrusted code execution from secret usage. 🔒 Secure Patterns1. Use
|
Beta Was this translation helpful? Give feedback.
-
|
This is a deliberate security restriction. There are two solid patterns depending on your use case: Pattern 1: Create a separate workflow that triggers after your PR checks complete. It runs in the context of the base repo and has full access to secrets: on:
workflow_run:
workflows: ["CI"]
types: [completed]
jobs:
use-secrets:
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request'
steps:
- uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy preview
env:
API_KEY: ${{ secrets.API_KEY }}
run: ./deploy.shThe PR workflow builds and uploads artifacts, the Pattern 2: This event runs in the base repo context and has secrets, but be careful: never check out the PR's code ( For most use cases involving external contributors, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
🏷️ Discussion Type
Question
💬 Feature/Topic Area
ARC (Actions Runner Controller)
Discussion Details
Hi, I'm Kiran, and I work at Bright Steel Centre. I noticed that secrets are not accessible when workflows are triggered from forked repositories. Is there a secure way to handle secrets for external contributions?
Beta Was this translation helpful? Give feedback.
All reactions