CI/CD Integration
Automatically keep your StackShare stack updated with continuous scanning in your CI/CD pipeline.
Integrate the StackShare CLI into your CI/CD pipeline to automatically keep your stack up-to-date whenever your project dependencies change.
Why Continuous Scanning?
- Stay current - Your stack automatically reflects your actual tools
- Zero maintenance - No manual updates required
- Audit trail - Track how your stack evolves over time
- Team visibility - Everyone sees the latest tools being used
GitHub Actions
Add this workflow to automatically update your stack when relevant files change:
# .github/workflows/update-stack.yml
name: Update StackShare
on:
push:
branches: [main]
paths:
- 'package.json'
- 'pnpm-lock.yaml'
- 'yarn.lock'
- 'package-lock.json'
- '*.config.*'
- 'Dockerfile'
- 'docker-compose.yml'
- '.github/workflows/**'
- 'prisma/**'
- 'requirements.txt'
- 'pyproject.toml'
- 'Gemfile'
- 'go.mod'
jobs:
update-stack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Scan and update stack
run: npx stackshare scan --yes --stack my-project
env:
STACKSHARE_API_KEY: ${{ secrets.STACKSHARE_API_KEY }}API Key Setup
Generate an API key from your account settings and add it as a repository secret named STACKSHARE_API_KEY.
GitLab CI
# .gitlab-ci.yml
update-stackshare:
stage: deploy
image: node:20
only:
refs:
- main
changes:
- package.json
- "*.config.*"
script:
- npx stackshare scan --yes --stack my-project
variables:
STACKSHARE_API_KEY: $STACKSHARE_API_KEYCircleCI
# .circleci/config.yml
version: 2.1
jobs:
update-stackshare:
docker:
- image: cimg/node:20.0
steps:
- checkout
- run:
name: Update StackShare
command: npx stackshare scan --yes --stack my-project
workflows:
update-stack:
jobs:
- update-stackshare:
filters:
branches:
only: mainAzure Pipelines
# azure-pipelines.yml
trigger:
branches:
include:
- main
paths:
include:
- package.json
- "*.config.*"
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '20.x'
- script: npx stackshare scan --yes --stack my-project
displayName: 'Update StackShare'
env:
STACKSHARE_API_KEY: $(STACKSHARE_API_KEY)Best Practices
Use Path Filters
Only trigger updates when relevant files change. This prevents unnecessary API calls and keeps your CI faster.
Use a Dedicated Stack
Create a stack specifically for your repository using the --stack flag with your stack's slug.
Monitor for Failures
Set up notifications for failed scans so you can address authentication or API issues quickly.
Consider Rate Limits
If you have many repositories updating simultaneously, consider adding slight delays or running updates at different times.
Environment Variables
The CLI accepts authentication via environment variable:
| Variable | Description |
|---|---|
STACKSHARE_API_KEY | Your StackShare API key for authentication |
Command Reference
For CI/CD usage, the most common command is:
npx stackshare scan --yes --stack <stack-slug>Options:
-y, --yes- Skip prompts, post automatically-s, --stack <slug>- Update a specific stack by slug-j, --json- Output results as JSON (useful for parsing in scripts)-n, --dry-run- Scan only, don't post (useful for testing)
Troubleshooting
Authentication Errors
Make sure your STACKSHARE_API_KEY environment variable is set correctly and the key is valid.
Stack Not Found
Verify the stack slug is correct. You can find it in the URL of your stack page (e.g., stackshare.io/username/my-stack → slug is my-stack).
No Tools Detected
Ensure your repository files are checked out completely. Some CI systems do shallow clones that may miss certain files.