Introduction
The ShardCloud GitHub Action allows you to deploy your application to Shard Cloud directly from your GitHub workflows. Automate deployments, backups, restarts, and more with simple workflow configurations. This action installs the ShardCloud CLI and allows you to execute ShardCloud commands as part of your CI/CD pipeline.Prerequisites
Before setting up GitHub Actions, you’ll need:- A ShardCloud account
- A GitHub repository
- A ShardCloud API key (get it from Dashboard → Config → Integrations)
Setup
Step 1: Get Your ShardCloud API Key
1
Navigate to Integrations
Go to the Shard Cloud Dashboard and navigate
to Config → Integrations.
2
Generate API Key
Generate or copy your API key. This key will be used to authenticate with
the ShardCloud CLI in your GitHub workflows.
Step 2: Add Secret to GitHub
1
Open Repository Settings
Go to your GitHub repository and navigate to Settings → Secrets and
variables → Actions.
2
Create New Secret
Click New repository secret and create a secret with: - Name:
SHARD_CLOUD_API_KEY - Value: Your ShardCloud API key Click Add
secret.Step 3: Create Workflow File
Create a.github/workflows/deploy.yml file in your repository. You can use any of the examples below based on your needs.
Usage Examples
Basic Deployment
Deploy your application to Shard Cloud on every push to the main branch:.github/workflows/deploy.yml
Replace
<app_id> with your actual Shard Cloud application ID. You can find
this in your application’s dashboard URL or settings.Deploy and Restart
Commit your changes and restart the application in one workflow:.github/workflows/deploy.yml
Backup Before Deploy
Create a backup before deploying new changes to ensure you can rollback if needed:.github/workflows/deploy.yml
Custom Working Directory
Execute commands from a specific directory (useful for monorepos):.github/workflows/deploy.yml
Multi-Environment Deployment
Deploy to different environments based on the branch:.github/workflows/deploy.yml
Action Inputs
The ShardCloud GitHub Action supports the following inputs:Available Commands
The action supports every ShardCloud CLI v2 command, which are grouped by resource:shardcloud <resource> <verb> (app, db, vm, backup, lb, image). Common commands include:
app commit <app_id>- Deploy changes to your applicationapp restart <app_id>- Restart your applicationbackup create <app_id>- Create a backup — this now works identically for apps, databases, and VMs, not just appsapp logs <app_id>- View application logs- And more - refer to the ShardCloud CLI documentation for a complete list
Best Practices
Use Secrets
Always store your API key in GitHub Secrets. Never hardcode credentials.
Create Backups
Create backups before major deployments to ensure you can rollback if
needed.
Use Specific Branches
Use specific branches for production deployments to prevent accidental
deployments.
Combine Commands
Combine multiple commands to create complex deployment workflows.
Troubleshooting
Action fails with authentication error
Action fails with authentication error
Verify that your
SHARD_CLOUD_API_KEY secret is correctly set in your
repository settings. Ensure the API key is valid and hasn’t expired. Check
the action logs for specific error messages.Commands not executing
Commands not executing
Verify that your
commands input is correctly formatted. For multiple
commands, use a multi-line string with |. Check that your app_id is
correct.Deployment fails
Deployment fails
Check the action logs for specific error messages. Verify your
.shardcloud
configuration is valid. Ensure all required files are in your repository.Working directory not found
Working directory not found
Verify that the
workdir path is correct relative to your repository root.
Ensure the directory exists in your repository.