Skip to main content

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 DashboardConfigIntegrations)

Setup

Step 1: Get Your ShardCloud API Key

1

Navigate to Integrations

Go to the Shard Cloud Dashboard and navigate to ConfigIntegrations.
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 SettingsSecrets and variablesActions.
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.
Always store your API key in GitHub Secrets. Never hardcode it in your workflow files or commit it to your repository.

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 all ShardCloud CLI commands. Common commands include:
  • commit <app_id> - Deploy changes to your application
  • restart <app_id> - Restart your application
  • backup <app_id> - Create a backup of your application
  • 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

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.
Verify that your commands input is correctly formatted. For multiple commands, use a multi-line string with |. Check that your app_id is correct.
Check the action logs for specific error messages. Verify your .shardcloud configuration is valid. Ensure all required files are in your repository.
Verify that the workdir path is correct relative to your repository root. Ensure the directory exists in your repository.

Additional Resources