This action runs a Hyphen deployment from a GitHub workflow. It wraps the hx deploy CLI command, waits for the deployment run to finish, and exposes the resulting deployment ID, run ID, URL, and status as step outputs so subsequent steps can act on them.
Table of Contents
Prerequisites
Before using the deploy action, ensure that:
- The Setup hx Command Line action has been run.
- Your repository contains a
.hxfile at the root (created byhx init), or you supply the project, app, and organization values as action inputs. - A deployment has been configured for the project environment you wish to deploy.
- Your cloud provider has been connected to Hyphen and a container registry has been created for the project.
- A Hyphen API key is available with appropriate permissions for deployment.
A Dockerfile will be used if present, and if not, Hyphen Code will generate one automatically. See Builds for more details.
Setting up GitHub Secrets
Add your Hyphen API key to your repository's secrets:
- In your GitHub repository, go to Settings > Secrets and variables > Actions.
- Click New repository secret.
- Name:
HYPHEN_API_KEY. - Value: Your Hyphen API key from the Hyphen App.
- Click Add secret.
Parameters
All parameters are optional. When omitted, the CLI falls back to values from the .hx file at the repository root and auto-detects the development environment.
deploymentId(optional): A specific deployment ID to run (e.g.,depl_abc123). When omitted, deploys the development environment.environment(optional): The environment to deploy (maps to--env).project(optional): The project to deploy (maps to--project). Defaults toproject_idfrom the.hxfile.organization(optional): The organization ID (maps to--organization).apps(optional): A comma-separated list of apps to deploy, each optionally specifying a build (e.g.,app1,app2:latest,app3:abld_xxx).noBuild(optional): Skip the build step and use the latest build. Defaults tofalse.dockerfile(optional): Path to the Dockerfile (e.g.,./Dockerfileor./docker/Dockerfile.prod).preview(optional): Preview name to deploy to (maps to--preview).prefix(optional): Host prefix for the preview deployment (maps to--prefix).path(optional): Path, if changed from the default, where the repository has been cloned.verbose(optional): Enable verbose logging. Defaults tofalse.
Outputs
The action sets the following step outputs, available to subsequent steps as steps.:
deployment-id: The deployment ID that was run.run-id: The deployment run ID.deployment-url: URL to the deployment run in the Hyphen dashboard.status: Final status of the deployment run (succeeded | failed | canceled).reason: Failure reason when status is notsucceeded. Empty on success.
Example Usage
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: setup hx CLI
id: setup
uses: Hyphen/setup-hx-action@v1
with:
apiKey: ${{ secrets.HYPHEN_API_KEY }}
- name: Deploy
id: deploy
uses: Hyphen/deploy-action@v1
with:
environment: production
- name: Report deployment URL
run: echo "Deployed at ${{ steps.deploy.outputs.deployment-url }}"
Deploying on Push to Main and on Release
This workflow deploys to development when a PR is merged to main, and to production when a release is created.
name: Deploy Application
on:
push:
branches:
- main
release:
types: [created]
jobs:
deploy-dev:
name: Deploy to Development
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Hyphen CLI
uses: Hyphen/setup-hx-action@v1
with:
apiKey: ${{ secrets.HYPHEN_API_KEY }}
- name: Deploy to Development
id: deploy
uses: Hyphen/deploy-action@v1
with:
environment: development
- name: Report deployment URL
run: echo "Deployed at ${{ steps.deploy.outputs.deployment-url }}"
deploy-prod:
name: Deploy to Production
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Hyphen CLI
uses: Hyphen/setup-hx-action@v1
with:
apiKey: ${{ secrets.HYPHEN_API_KEY }}
- name: Deploy to Production
id: deploy
uses: Hyphen/deploy-action@v1
with:
environment: production
- name: Report deployment URL
run: echo "Deployed at ${{ steps.deploy.outputs.deployment-url }}"
Pulling ENV Secrets Before Deploying
If your deployment depends on Hyphen ENV secrets, add the ENV action before the deploy step:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Hyphen CLI
uses: Hyphen/setup-hx-action@v1
with:
apiKey: ${{ secrets.HYPHEN_API_KEY }}
- name: Pull ENV secrets
uses: Hyphen/env-action@v1
with:
hxKeyFile: ${{ secrets.HYPHEN_KEY_FILE }}
environment: production
outputs: files
- name: Deploy
uses: Hyphen/deploy-action@v1
with:
environment: production
How It Works
When the deploy action runs:
- The Hyphen CLI builds your Docker image (Hyphen Code generates a Dockerfile automatically if none exists).
- The image is pushed to your project's container registry (configured during setup).
- The application is deployed to your cloud provider according to the project environment deployment settings.
- Build, release, and verification steps are executed.
- The action waits for the deployment run to finish and exposes the result to subsequent steps via outputs.
For details on the build process, including Hyphen Code's Dockerfile auto-generation, see Builds.
Next Steps
- Learn more about Deployment Policies
- Understand the build process including Dockerfile auto-generation
- Manage environment variables in your deployments
- Explore CLI commands
- Set up environment variables and secrets