A GitHub Action that creates deployment records in the DX platform by making API calls to your DX instance. This action provides full support for the DX deployments.create API with all available parameters and attribution modes.
- name: Create DX Deployment
uses: Luscii/gha-dx-create-deployment@v1
with:
dx_instance: 'luscii' # for luscii.getdx.net
bearer: ${{ secrets.DX_BEARER_TOKEN }}
service: 'my-service-name'
# Optional - these default to current repo and commit:
# repository: ${{ github.repository }}
# commit_sha: ${{ github.sha }}- name: Create DX Deployment with Metadata
uses: Luscii/gha-dx-create-deployment@v1
with:
dx_instance: 'luscii'
bearer: ${{ secrets.DX_BEARER_TOKEN }}
service: 'payments-service'
environment: 'production'
success: 'true'
reference_id: ${{ github.run_id }}
source_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
source_name: 'GitHub Actions'
metadata: '{"version": "${{ steps.get_version.outputs.version }}", "branch": "${{ github.ref_name }}"}'
integration_branch: 'develop'- name: Create DX Deployment for Multiple Commits
uses: Luscii/gha-dx-create-deployment@v1
with:
dx_instance: 'luscii'
bearer: ${{ secrets.DX_BEARER_TOKEN }}
service: 'web-frontend'
merge_commit_shas: '["a0e61dfff93b2b07", "788cacf2c1cb3948", "ed4a39b2f1c8d9e7"]'
environment: 'staging'DX supports several paths to attributing deployments to code changes. This action supports all of them:
When only the repository is provided (or defaults), the deployment is attributed to all non-deployed pull requests in the specified repository with base refs equal to the default branch.
When commit_sha and repository are provided, the deployment is attributed to the matching pull request as well as all previous non-deployed pull requests with the same repository and base ref.
When commit_sha, repository, and integration_branch are provided, the deployment is attributed only to pull requests merged into the integration branch.
When merge_commit_shas is provided, the deployment is attributed to the specific pull requests that correspond to the provided SHAs.
| Input | Description | Required | Default |
|---|---|---|---|
dx_instance |
DX instance name (e.g., "luscii" for luscii.getdx.net) | Yes | - |
bearer |
Bearer token for authentication | Yes | - |
service |
Service name for the deployment | Yes | - |
repository |
Repository name in format "owner/repo" | No | ${{ github.repository }} |
commit_sha |
Commit SHA for the deployment | No | ${{ github.sha }} |
deployed_at |
Deployment timestamp (Unix timestamp) | No | Current time |
reference_id |
Unique identifier for the deployment | No | - |
source_url |
External URL with more info about deployment | No | - |
source_name |
Source for the deployment (e.g., "GitHub Actions") | No | - |
metadata |
JSON object with additional data | No | - |
integration_branch |
Integration branch name | No | - |
success |
Whether deployment was successful (true/false) | No | - |
environment |
Environment name | No | "production" |
merge_commit_shas |
JSON array of commit SHAs for multi-commit attribution | No | - |
| Output | Description |
|---|---|
response |
Full JSON response from the DX API |
deployment_id |
The deployment ID returned by DX (if available) |
name: Deploy and Record in DX
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy application
run: |
# Your deployment steps here
echo "Deploying application..."
- name: Record deployment in DX
uses: Luscii/gha-dx-create-deployment@v1
with:
dx_instance: 'luscii'
bearer: ${{ secrets.DX_BEARER_TOKEN }}
service: 'my-web-service'name: Batch Deploy Multiple Services
on:
workflow_dispatch:
inputs:
commit_shas:
description: 'JSON array of commit SHAs to deploy'
required: true
default: '["abc1234", "def5678"]'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy batch of commits
run: |
echo "Deploying commits: ${{ github.event.inputs.commit_shas }}"
# Batch deployment logic here
- name: Record batch deployment in DX
uses: Luscii/gha-dx-create-deployment@v1
with:
dx_instance: 'luscii'
bearer: ${{ secrets.DX_BEARER_TOKEN }}
service: 'batch-processor'
merge_commit_shas: ${{ github.event.inputs.commit_shas }}
environment: 'production'
success: 'true'
source_name: 'Batch Deployment System'This action makes a POST request to https://{dx_instance}.getdx.net/api/deployments.create using the full DX deployments.create API.
{
"service": "my_service",
"repository": "orgname/repository",
"commit_sha": "abc1234",
"deployed_at": 1700000000,
"environment": "production",
"success": true,
"reference_id": "deploy-123",
"source_url": "https://argocd.example.com/app/my-app",
"source_name": "ArgoCD",
"metadata": {
"version": "1.2.3",
"branch": "main"
}
}{
"service": "my_service",
"merge_commit_shas": ["abc1234", "def5678"],
"deployed_at": 1700000000,
"environment": "staging",
"success": true
}The request includes:
Content-Type: application/jsonheaderAuthorization: Bearer {token}headerUser-Agent: gha-dx-create-deployment/1.0.0header
The action includes comprehensive validation:
dx_instance: Must be a non-empty stringbearer: Must be a non-empty stringservice: Must be a non-empty string
- Single Commit Mode: Requires
repositoryandcommit_sha(can use defaults) - Multi-Commit Mode: Requires
merge_commit_shasas a JSON array - Cannot use both modes simultaneously
metadata: Must be valid JSON object if providedmerge_commit_shas: Must be valid JSON array of strings if provided
success: Must be "true" or "false" if provided (case-insensitive)
- Store your DX bearer token as a GitHub secret (e.g.,
DX_BEARER_TOKEN) - Use this action in your workflow after your deployment steps
- Ensure your DX instance is accessible from GitHub Actions runners
The action properly handles DX API responses by always checking the ok parameter in responses. It will fail if:
- Required inputs (
dx_instance,bearer,service) are missing - Attribution mode parameters are invalid or conflicting
- JSON parameters contain invalid JSON
- Boolean parameters contain invalid values
- The API request fails (network issues, authentication errors, etc.)
- The DX API returns an error response with
ok: false
The action handles these expected DX API error codes:
| Error Code | Description |
|---|---|
not_authed |
API request does not include a valid API key for authentication |
invalid_auth |
The provided API key is invalid, expired, or does not exist |
account_inactive |
The user account associated with the API key is deactivated or suspended |
invalid_json |
The JSON body of the request could not be parsed |
required_params_missing |
One or more required parameters were not provided in the request |
repo_not_found |
The specified repository could not be found |
Note: Other errors can be returned if the service is down or other unexpected factors affect processing. The action is designed to handle any error code returned by the API.
Error details will be logged to help with troubleshooting.
For complete API documentation, see the official DX deployments.create API documentation.