Is it possible to get an actor specific token or set the actor in a deployment when calling from the API? #156080
Replies: 4 comments
-
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
Hi @humphreyja, You’re right — the GitHub API for creating deployments uses the token’s identity, so the actor is implicitly the token owner (often If you want the deployment dashboard to show who triggered the deployment, a common workaround is to:
However, this requires securely managing tokens and possibly user-specific tokens, which can be complex. So in short, there is no built-in way to “set” or override the actor in the deployment API call. The actor is always the token’s identity. Hope this helps! Let me know if you want some examples or best practices around token usage for this. |
Beta Was this translation helpful? Give feedback.
-
Hey! Unfortunately, you can't directly set a custom actor when using the GitHub API for deployments. The actor is indeed tied to the token being used, and with GITHUB_TOKEN it will always show as "github-actions". However, there are a few workarounds: Option 1: Use the deployment description/environment
Option 2: Personal Access Token (not recommended for actions) If you use a PAT instead of GITHUB_TOKEN, it would show that user as the actor, but this breaks the security model of Actions. Option 3: Custom deployment status with actor info
The GitHub API intentionally doesn't allow actor spoofing for security reasons. Your best bet is using the description field to track who initiated the deployment. Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
🧩 GitHub Actions: Custom Deployment Shows "github-actions" Instead of Actual ActorWhen using a custom JavaScript GitHub Action to call the REST API (e.g. 🤔 Why Can’t I Set the Actor?GitHub’s API does not allow setting the If you use the built-in ✅ Workarounds / Suggestions1. Use a Personal Access Token (PAT)Instead of the default env:
GH_TOKEN: ${{ secrets.DEPLOYER_PAT }}
steps:
- name: Create deployment
run: |
curl -X POST \
-H "Authorization: Bearer $GH_TOKEN" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/${{ github.repository }}/deployments \
-d '{ "ref": "main", "required_contexts": [], "environment": "production" }'
2. Log the Triggering Actor ManuallyAs a workaround, log the actual triggering user manually using const actor = process.env.GITHUB_ACTOR;
console.log(`Triggered by: ${actor}`); You could also tag the deployment or include the actor name in the description or payload: description: `Deployment triggered by ${actor}` 3. Use GitHub’s
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Question
Body
When using a GitHub custom JS action, making a call to something like
createDeployment
doesn't allow you to set the actor. If for example the action is manually triggered or triggered from a merge, it'd be nice to show on the deployments dashboard who triggered that deployment. But the API doesn't allow you to set that. I assume it is based off the token given to the API. But doing so just shows that the deployment was created by gh-actions.Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions