Skip to content

Git Storage

Store deployment scripts in version-controlled Git repositories.

Git storage clones repositories and reads scripts from the local clone:

Use CaseRecommendation
Version controlTrack all script changes
GitOps workflowsPR-based review processes
Audit trailsGit history for compliance
Team collaborationMultiple contributors
Branch strategiesDifferent scripts per environment
PropertyRequiredDescription
NameYesUnique identifier for the storage
URLYesGit repository URL
ReferenceYesBranch, tag, or commit to checkout
PathYesLocal path for cloned repository
AuthenticationNoCredentials for private repositories
┌─────────────────────────────────────────────────────────────┐
│ Create Git Storage │
├─────────────────────────────────────────────────────────────┤
│ │
│ Name * │
│ [deployment-scripts ] │
│ │
│ Repository URL * │
│ [https://github.com/org/scripts.git ] │
│ │
│ Reference * │
│ [main ] │
│ Branch, tag, or commit SHA │
│ │
│ Local Path * │
│ [/var/mantis/cache/scripts ] │
│ Where to clone the repository │
│ │
│ Authentication │
│ [github-deploy-key ▼] │
│ Select authentication method │
│ │
│ [Cancel] [Create] │
│ │
└─────────────────────────────────────────────────────────────┘
  1. Navigate to Storage in the sidebar (under Infrastructure)
  2. Click New Storage
  3. Click the Git Storage tab
  4. Enter repository details
  5. Select authentication method
  6. Click Create

Git storage is created through POST /api/v1/storage/git. The reference field takes a branch, tag, or commit, and auth_id references a git auth credential (see Authentication).

Terminal window
# Create git storage with SSH key auth
curl -X POST "$MANTIS_URL/api/v1/storage/git" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{
"name": "deployment-scripts",
"url": "git@github.com:org/scripts.git",
"reference": "main",
"path": "/var/mantis/cache/scripts",
"auth_id": "<github-ssh-auth-id>"
}'
# Create with a specific tag
curl -X POST "$MANTIS_URL/api/v1/storage/git" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{
"name": "versioned-scripts",
"url": "https://github.com/org/scripts.git",
"reference": "v1.2.3",
"path": "/var/mantis/cache/versioned"
}'
deployment-scripts/
├── README.md
├── deploy/
│ ├── web-app.sh
│ ├── api-service.sh
│ └── database.sh
├── configure/
│ ├── nginx.conf.sh
│ └── ssl-setup.sh
├── health/
│ ├── check-web.sh
│ └── check-db.sh
└── rollback/
└── restore.sh

Reference scripts relative to repository root:

RepositoryFilenameFile Location
scripts.gitdeploy/web-app.shrepo/deploy/web-app.sh
scripts.gitconfigure/nginx.conf.shrepo/configure/nginx.conf.sh
┌─────────────────────────────────────────────────────────────┐
│ Git Storage: deployment-scripts │
├─────────────────────────────────────────────────────────────┤
│ │
│ Type: Git │
│ URL: git@github.com:org/scripts.git │
│ Reference: main │
│ Local Path: /var/mantis/cache/scripts │
│ Auth: github-deploy-key │
│ Created: January 15, 2024 │
│ │
│ ───────────────────────────────────────────────────────── │
│ │
│ Last Fetched: 5 minutes ago │
│ │
│ [Edit] [Delete] │
│ │
└─────────────────────────────────────────────────────────────┘

The git repository is synced on every read. File content is cached by commit hash, so the cache invalidates automatically whenever the repository’s HEAD commit changes — the first read after a new commit re-fetches, and subsequent reads of the same commit are served from cache. There is no time-based cache expiry to configure and no manual “refresh” action.

Use different branches for different environments:

Repository: scripts.git
├── main # Production scripts
├── staging # Staging scripts
└── development # Development scripts

Create a separate storage source per branch by setting reference accordingly ("main", "staging", "development"):

Terminal window
curl -X POST "$MANTIS_URL/api/v1/storage/git" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{
"name": "scripts-prod",
"url": "git@github.com:org/scripts.git",
"path": "/var/mantis/cache/scripts-prod",
"reference": "main"
}'

Use tags for immutable versions by setting reference to a tag:

{
"name": "scripts-v1",
"url": "git@github.com:org/scripts.git",
"path": "...",
"reference": "v1.2.3",
}

Pin to a specific commit for reproducibility by setting reference to a SHA:

{
"name": "scripts-pinned",
"url": "git@github.com:org/scripts.git",
"path": "...",
"reference": "abc123def456789",
}

Git storage supports multiple authentication methods. See Authentication for detailed setup.

MethodUse CaseURL Format
SSH KeyDeploy keys, personal accessgit@github.com:org/repo.git
HTTPS + TokenGitHub/GitLab tokenshttps://github.com/org/repo.git
HTTPS + PasswordBasic auth (deprecated)https://github.com/org/repo.git
Terminal window
# Create an SSH git auth credential
curl -X POST "$MANTIS_URL/api/v1/storage/git/auth" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d "{
\"name\": \"github-deploy-key\",
\"auth_type\": \"ssh_key\",
\"ssh_private_key\": \"$(cat ~/.ssh/deploy_key)\"
}"
# Reference its returned id (auth_id) when creating git storage
curl -X POST "$MANTIS_URL/api/v1/storage/git" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{
"name": "scripts",
"url": "git@github.com:org/scripts.git",
"path": "/var/mantis/cache/scripts",
"reference": "main",
"auth_id": "<github-deploy-key-auth-id>"
}'
  1. Branch: Create feature branch for changes
  2. Commit: Add script changes
  3. Review: Create PR for team review
  4. Merge: Merge to target branch after approval
  5. Deploy: Mantis fetches and uses updated scripts

Create a separate git storage source per repository (each needs a path and reference):

{ "name": "app-deploy", "url": "git@github.com:org/app-scripts.git", "path": "/var/mantis/cache/app-deploy", "reference": "main" }
{ "name": "infra-config", "url": "git@github.com:org/infra-config.git", "path": "/var/mantis/cache/infra-config", "reference": "main" }
{ "name": "shared-utils", "url": "git@github.com:org/shared-scripts.git","path": "/var/mantis/cache/shared-utils", "reference": "main" }

For monorepos, scripts can be in subdirectories:

monorepo/
├── src/
├── docs/
└── deploy/
└── scripts/
├── web.sh
└── api.sh

When creating an action against this storage source (in Lens, or via the Actions API), set the action’s filename to include the subdirectory path, e.g. deploy/scripts/web.sh. See Creating Actions.

For production, use repository-specific deploy keys:

ApproachSecurityRecommendation
Deploy keysHighRecommended for production
Personal tokensMediumOK for development
User passwordsLowAvoid

Use immutable tags for production deployments:

// Good: pin reference to an immutable tag
{ "name": "prod-scripts", "reference": "v2.1.0", "url": "...", "path": "..." }
// Avoid: a mutable branch in production (can change unexpectedly)
{ "name": "prod-scripts", "reference": "main", "url": "...", "path": "..." }

Document your scripts repository:

# Deployment Scripts
## Structure
- `deploy/` - Deployment scripts
- `configure/` - Configuration scripts
- `health/` - Health check scripts
## Usage
Scripts are used by Mantis for automated deployments.
## Contributing
1. Create feature branch
2. Make changes
3. Submit PR for review

Validate scripts before merging:

.github/workflows/validate.yml
on: [pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Lint scripts
run: shellcheck deploy/*.sh

Cause: Wrong URL or missing access

Solution:

  1. Verify repository URL is correct
  2. Check authentication is configured
  3. Ensure deploy key has read access

Cause: Branch/tag doesn’t exist

Solution:

  1. Verify branch or tag name
  2. Check if reference was deleted
  3. Update storage with correct reference

Cause: Invalid or expired credentials

Solution:

  1. Regenerate SSH key or token
  2. Update authentication in Mantis
  3. Verify key is added to Git provider

Cause: Large repository or slow network

Solution:

  1. Consider repository size reduction
  2. Check network connectivity