Deploying with external CI
You can easily integrate Stacktape into any CI/CD pipeline to automate your deployments. This guide provides instructions for GitHub Actions, GitLab CI/CD, and Bitbucket Pipelines.
Prerequisites
Before you begin, make sure you have the following:
- A Stacktape account.
- An AWS account connected to your Stacktape organization.
- A Stacktape project.
- A Stacktape API key to authenticate your CI/CD pipeline.
- A
stacktape.yml
orstacktape.ts
configuration file in your repository.
You can create all of these resources in the Stacktape console.
General CI/CD Configuration
A typical CI/CD pipeline for a Stacktape application consists of two steps:
- Install Stacktape:
curl -L https://installs.stacktape.com/linux.sh | bash
- Deploy your application:
stacktape deploy --projectName <your-project> --stage <your-stage> --region <your-region>
You will also need to provide your STACKTAPE_API_KEY
as a secret or environment variable in your CI/CD pipeline.
Deployment Options
Stacktape offers two commands for deploying your application:
deploy
: This command packages your application and deploys it from within the CI/CD environment. It requires Docker and Node.js to be installed in the CI/CD runner.codebuild:deploy
: This command offloads the packaging and deployment process to CodeBuild in your AWS account. This is the recommended approach, as it doesn't require any dependencies in your CI/CD runner and is generally faster and more reliable.
GitHub Actions
Create a repository secret
In your GitHub repository, go to Settings > Secrets and variables > Actions, and create a new secret named
STACKTAPE_API_KEY
with your API key as the value.
Add a workflow file
Create a file named .github/workflows/deploy.yml
in your repository with the following configuration:
name: Deploy to Stacktapeon:push:branches:- mainjobs:deploy:runs-on: ubuntu-lateststeps:- name: Checkout repositoryuses: actions/checkout@v4- name: Install Stacktaperun: curl -L https://installs.stacktape.com/linux.sh | bash- name: Deploy to Stacktaperun: stacktape codebuild:deploy --projectName <your-project> --stage <your-stage> --region <your-region>env:STACKTAPE_API_KEY: ${{ secrets.STACKTAPE_API_KEY }}
GitLab CI/CD
Create a CI/CD variable
In your GitLab project, go to Settings > CI/CD, expand the Variables section, and click Add variable. Create
a variable named STACKTAPE_API_KEY
with your API key as the value. Make sure to select the Masked option.
Add a .gitlab-ci.yml file
Create a file named .gitlab-ci.yml
in the root of your repository with the following configuration:
deploy:image: node:latestrules:- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCHscript:- curl -L https://installs.stacktape.com/linux.sh | bash- export PATH=$PATH:/root/.stacktape/bin- stacktape codebuild:deploy --projectName <your-project> --stage <your-stage> --region <your-region>
Bitbucket Pipelines
Create a repository variable
In your Bitbucket repository, go to Repository settings > Pipelines > Repository variables. Create a variable named
STACKTAPE_API_KEY
with your API key as the value. Make sure to select the Secured option.
Add a bitbucket-pipelines.yml file
Create a file named bitbucket-pipelines.yml
in the root of your repository with the following configuration:
image: atlassian/default-image:4pipelines:default:- step:name: "Deploy to Stacktape"deployment: productionscript:- curl -L https://installs.stacktape.com/linux.sh | sh- export PATH="/root/.stacktape/bin:${PATH}"- stacktape codebuild:deploy --projectName <your-project> --stage <your-stage> --region <your-region>