CI/CD Integration
Integrate the LegionEdge Platform with your CI/CD pipelines
The LegionEdge Platform integrates with popular CI/CD systems to automate deployments, run tests against platform resources, and manage environment promotion.
GitHub Actions
Deploy on Push
# .github/workflows/deploy.yml
name: Deploy to LegionEdge
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Deploy to staging
uses: legionedge/deploy-action@v2
with:
api-key: ${{ secrets.LEGIONEDGE_API_KEY }}
project-id: ${{ vars.LEGIONEDGE_PROJECT_ID }}
environment: staging
- name: Promote to production
if: github.ref == 'refs/heads/main'
uses: legionedge/deploy-action@v2
with:
api-key: ${{ secrets.LEGIONEDGE_API_KEY }}
project-id: ${{ vars.LEGIONEDGE_PROJECT_ID }}
environment: production
promote-from: stagingDeploy on Release
name: Release Deploy
on:
release:
types: [published]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: legionedge/deploy-action@v2
with:
api-key: ${{ secrets.LEGIONEDGE_API_KEY }}
project-id: ${{ vars.LEGIONEDGE_PROJECT_ID }}
environment: production
version: ${{ github.event.release.tag_name }}GitLab CI
# .gitlab-ci.yml
stages:
- test
- deploy-staging
- deploy-production
test:
stage: test
image: node:20
script:
- npm ci
- npm test
deploy-staging:
stage: deploy-staging
image: node:20
script:
- npm install -g @legionedge/cli
- legionedge deploy --project $LEGIONEDGE_PROJECT_ID --env staging
environment:
name: staging
only:
- main
deploy-production:
stage: deploy-production
image: node:20
script:
- npm install -g @legionedge/cli
- legionedge deploy --project $LEGIONEDGE_PROJECT_ID --env production --promote-from staging
environment:
name: production
when: manual
only:
- mainCustom Pipelines with the CLI
Install the LegionEdge CLI for any CI/CD system:
npm install -g @legionedge/cliCommon CLI Commands
# Authenticate
legionedge auth login --api-key $LEGIONEDGE_API_KEY
# Deploy
legionedge deploy --project proj_abc123 --env staging
# Check deployment status
legionedge deploy status --project proj_abc123 --env staging
# Promote to production
legionedge deploy promote --project proj_abc123 --from staging --to production
# Rollback
legionedge deploy rollback --project proj_abc123 --env productionDeployment Automation with SDK
For advanced workflows, use the SDK directly in your pipeline scripts:
// scripts/deploy.ts
import { LegionEdge } from "@legionedge/sdk";
const client = new LegionEdge({
apiKey: process.env.LEGIONEDGE_API_KEY!,
});
async function deploy() {
const projectId = process.env.LEGIONEDGE_PROJECT_ID!;
const environment = process.env.DEPLOY_ENV || "staging";
const commitSha = process.env.CI_COMMIT_SHA || "unknown";
const deployment = await client.deployments.create({
projectId,
environment,
source: {
type: "git",
commit: commitSha,
},
config: {
instances: environment === "production" ? 4 : 2,
},
});
console.log(`Deployment started: ${deployment.id}`);
// Wait for deployment to complete
const result = await client.deployments.waitForCompletion(deployment.id, {
timeout: 300_000, // 5 minutes
pollInterval: 5_000,
});
if (result.status === "failed") {
console.error(`Deployment failed: ${result.error}`);
process.exit(1);
}
console.log(`Deployment successful: ${result.url}`);
}
deploy();Run it from any CI system:
npx tsx scripts/deploy.tsEnvironment Variables Reference
| Variable | Description |
|---|---|
LEGIONEDGE_API_KEY | API key for authentication |
LEGIONEDGE_PROJECT_ID | Target project ID |
DEPLOY_ENV | Target environment |
CI_COMMIT_SHA | Git commit SHA (auto-set by most CI systems) |
Next Steps
- Configure webhooks to trigger pipelines on platform events.
- Review deployment best practices for production readiness.