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
Navigate to Integrations
Go to the Shard Cloud Dashboard and navigate to
Config → Integrations.
Step 2: Add Secret to GitHub
Open Repository Settings
Go to your GitHub repository and navigate to Settings → Secrets and
variables → Actions.
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:| Input | Required | Default | Description |
|---|---|---|---|
token | Yes | - | ShardCloud API Key (store in secrets) |
commands | No | - | ShardCloud CLI commands to execute |
workdir | No | . | Working directory for command execution |
Available Commands
The action supports all ShardCloud CLI commands. Common commands include:commit <app_id>- Deploy changes to your applicationrestart <app_id>- Restart your applicationbackup <app_id>- Create a backup of your applicationlogs <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.