Github Actions
Use these Github Actions to connect Tapitalee to Github.
As published below, these actions can be manually activated in the Actions tab in Github. You can adjust them to suit your needs by consulting the Github documentation for Workflows.
Set up TAPIT_TOKEN secret
This is required to authorize Tapitalee to work in a Github Action.
In Tapitalee create a Deploy Token
$ tapit create deploy_token description='github'Copy the resulting toiken into a Github Secret under
Settings > Secrets and variables > Actions > New Repository Secret.
Automation
Manual deploys are defined by the workflow_dispatch: section. To make it run when someone merges code to the main branch, add this:
on:
push:
branches:
- masterAdd the files below to your git repo as needed.
Build image only
When you may want to test building without actually deploying.
# .github/workflows/build.yml
name: Manual Build
on:
workflow_dispatch:
inputs:
git_ref:
description: 'Git ref (branch, tag, or commit SHA) to checkout'
required: false
type: string
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: ${{ inputs.git_ref || github.sha }}
- name: Build using Tapit
uses: tapitalee/ghactions/image-build@staging
with:
tapit-token: ${{ secrets.TAPIT_TOKEN }}Build & deploy
Ideal for automating deploy on push to main.
# .github/workflows/deploy.yml
name: Manual Build & Deploy
on:
workflow_dispatch:
inputs:
cache:
description: 'Cache to use'
required: false
default: ''
type: choice
options:
- gha
- ecr
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Deploy using Tapit
uses: tapitalee/ghactions/image-deploy@staging
with:
tapit-token: ${{ secrets.TAPIT_TOKEN }}
cache: ${{ inputs.cache }}Multi-Process GitHub Actions Deployment
When using GitHub Actions to deploy apps with multiple processes, the image-deploy action will:
- Deploy all processes in your app by default
- Create separate deployments for each process
- Allow some processes to succeed while others fail
- Provide resilient deployments where failures are isolated to individual processes
If you need to deploy only specific processes, you can modify your workflow to use the CLI directly:
- name: Deploy specific process
run: |
npm install -g @tapitalee/cli
tapit create deploy process=worker docker_tag=$GITHUB_SHA
env:
TAPIT_TOKEN: ${{ secrets.TAPIT_TOKEN }}Run task
Allows running a command (eg. database migration). Note: This is for demo purposes only, do not use this on a public repository without additional security measures.
As configured, it will allow you to run a task from the Github Actions web interface, but you can modify it to run a specific command as needed, on the command: line.
# .github/workflows/run.yml
name: Run Task
on:
workflow_dispatch:
inputs:
command:
description: 'Command'
required: true
type: string
memory:
description: 'Memory allocation in GB'
required: true
default: '1'
type: string
cpu:
description: 'CPU allocation in cores'
required: true
default: '0.25'
type: string
jobs:
run-task:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create Task
uses: tapitalee/ghactions/create-task@staging
with:
tapit-token: ${{ secrets.TAPIT_TOKEN }}
memory: ${{ inputs.memory }}
cpu: ${{ inputs.cpu }}
command: ${{ inputs.command }}