GitHub Actions
Integrate Spectra.fm into your GitHub Actions workflow to automatically generate screenshots on releases, PRs, or any other trigger.
Basic Setup
Section titled “Basic Setup”Add this workflow to .github/workflows/screenshots.yml:
name: Generate Screenshotson: release: types: [published]
jobs: export: runs-on: ubuntu-latest steps: - name: Export screenshots run: | curl -X POST "https://api.spectra.fm/project/${{ vars.SPECTRA_PROJECT_ID }}/export" \ -H "X-API-Key: ${{ secrets.SPECTRA_API_KEY }}" \ -H "Content-Type: application/json" \ -d '{"combinations": [{"locale": "en", "theme": "light"}]}'Configuration
Section titled “Configuration”Required Secrets
Section titled “Required Secrets”Add these to your repository settings under Settings > Secrets and variables > Actions:
| Secret | Description |
|---|---|
SPECTRA_API_KEY | Your Spectra.fm API key |
Required Variables
Section titled “Required Variables”Add these under Settings > Secrets and variables > Actions > Variables:
| Variable | Description |
|---|---|
SPECTRA_PROJECT_ID | Your Spectra.fm project ID |
Advanced Examples
Section titled “Advanced Examples”Generate on PR for Preview
Section titled “Generate on PR for Preview”name: Preview Screenshotson: pull_request: types: [opened, synchronize]
jobs: preview: runs-on: ubuntu-latest steps: - name: Generate preview id: export run: | RESPONSE=$(curl -s -X POST "https://api.spectra.fm/project/${{ vars.SPECTRA_PROJECT_ID }}/export" \ -H "X-API-Key: ${{ secrets.SPECTRA_API_KEY }}" \ -H "Content-Type: application/json" \ -d '{"combinations": [{"locale": "en", "theme": "light"}]}') echo "response=$RESPONSE" >> $GITHUB_OUTPUT
- name: Comment PR uses: actions/github-script@v7 with: script: | github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: '📸 Screenshots generated! Check the Spectra.fm dashboard for previews.' })Multi-locale Export
Section titled “Multi-locale Export”- name: Export all locales run: | curl -X POST "https://api.spectra.fm/project/${{ vars.SPECTRA_PROJECT_ID }}/export" \ -H "X-API-Key: ${{ secrets.SPECTRA_API_KEY }}" \ -H "Content-Type: application/json" \ -d '{ "combinations": [ {"locale": "en", "theme": "light"}, {"locale": "en", "theme": "dark"}, {"locale": "de", "theme": "light"}, {"locale": "de", "theme": "dark"}, {"locale": "ja", "theme": "light"}, {"locale": "ja", "theme": "dark"} ] }'Next Steps
Section titled “Next Steps”- View the full API documentation
- Get your API key at app.spectra.fm/settings/api-keys