Get GitHub Token
Learn how to obtain GitHub tokens from sfp server for repository authentication in custom workflows without requiring a GitHub App
The get-github-token action fetches a GitHub authentication token from sfp server for repository operations. This provides a centralized way to obtain GitHub tokens without configuring GitHub Apps in each workflow, making it ideal for cross-repository operations and simplified authentication.
Overview
Many custom workflows need GitHub tokens for operations like cloning repositories, creating PRs, or posting comments. The get GitHub token action provides:
Centralized token management through sfp server
No GitHub App configuration required in workflows
Automatic token caching (50 minutes) to reduce API calls
Automatic retries with built-in retry logic for reliability
Secure token handling with automatic masking in logs
Fast execution without requiring Docker images
This makes it perfect for:
Cross-repository operations (accessing other repos)
Workflows that don't have GitHub App credentials
Centralized authentication management
Simplified workflow setup
How It Works
The action retrieves tokens from sfp server's authentication API:
Prerequisites
Before using this action:
sfp server is configured with GitHub integration:
SFP_SERVER_URLas a variableSFP_SERVER_TOKENas a secret
Repository is registered in sfp server as a project
No Docker image required - This action runs natively on Node.js
Referencing the Action
The get-github-token action is located in your sfops repository:
Basic Usage
Simple Token Retrieval
Get a token for the current repository:
Cross-Repository Access
Get a token for a different repository:
Use with Other Actions
Combine with other sfops actions that need GitHub tokens:
Input Reference
sfp-server-url
Yes
-
URL to sfp server instance
sfp-server-token
Yes
-
sfp server authentication token
repository
No
${{ github.repository }}
Repository in owner/repo format
Output Reference
token
GitHub installation token (masked in logs)
Comparison: get-github-token vs GitHub App Token
sfops provides two ways to obtain GitHub tokens. Choose based on your needs:
get-github-token (sfp server)
Best for:
Workflows using sfp server
Cross-repository operations
Centralized token management
Simplified setup (no App ID/private key needed)
actions/create-github-app-token
Best for:
Direct GitHub App authentication
Workflows not using sfp server
Fine-grained permission control
Standard sfops workflows
Common Use Cases
Dashboard Updates
Update the sfops dashboard repository:
PR Comments
Post comments on pull requests:
Multi-Repository Operations
Operate across multiple repositories:
Token Details
Token Characteristics
Type: GitHub App installation token
Scope: Repository-scoped (limited to specified repository)
Expiration: Valid for ~1 hour (generated fresh or from 50-min cache)
Permissions: Inherited from sfp server's GitHub App configuration
Security
The action automatically:
Masks the token in all GitHub Actions logs
Uses HTTPS for all API communications
Never logs the full token value
Retry Behavior
The action includes built-in retry logic:
Max retries: 3 attempts
Delay between retries: 5 seconds
Retryable errors: Network failures, temporary server errors
Troubleshooting
Repository Not Found (404)
If you receive a 404 error:
Verify the repository is registered as a project in sfp server
Check the repository name format (
owner/repo)Ensure the sfp server has access to the repository
Authentication Failed (403)
If you receive a 403 error:
Verify
SFP_SERVER_TOKENis correct and not expiredCheck the token has appropriate permissions in sfp server
Ensure the sfp server's GitHub App has access to the repository
Token Not Working
If the token doesn't work for your operation:
Verify the sfp server's GitHub App has required permissions
Check if the operation requires additional scopes
Try regenerating the token (cache may have stale permissions)
Last updated