Docker: Configure the GitHub Actions workflow
This documentation is part of the Deploy with GitHub Actions guide. View the full guide here: Learn how to deploy your Docker containers using GitHub Actions.
Welcome to the Stackhero documentation
Stackhero provides a ready-to-use Docker cloud CaaS (Containers as a Service) platform, designed for fast and reliable container deployments:
- Deploy to production with a single
docker-compose up. There is no extra setup: just start your containers.- Pick your own domain name, secured automatically with HTTPS (for example: https://api.your-company.com, https://www.your-company.com, or https://backoffice.your-company.com).
- Benefit from strong performance and robust security on private, dedicated infrastructure.
- Apply updates with one click for simple, low-effort maintenance.
You can have your containers live in production in about five minutes. Stackhero manages the infrastructure, updates, and security for you, so you can focus on delivering your applications. Read more about Docker CaaS cloud hosting.
On your local machine, navigate to your Git repository and create a directory called .github/workflows. Inside this directory, create a file named deploy-to-stackhero.yml with the following content:
# File: .github/workflows/deploy-to-stackhero.yml
name: Deploy to Stackhero
description: Deploy branch "${{ github.ref_name }}" to Stackhero
on:
push:
# These branches trigger the deploy action on push.
# Be sure to create an environment matching the branch name in GitHub (under Settings > Environments).
# Then add the secret STACKHERO_CERTIFICATES_PASSWORD and variable STACKHERO_ENDPOINT in that environment.
branches: [ "production", "staging" ]
jobs:
Deploy:
environment: ${{ github.ref_name }}
runs-on: ubuntu-latest
steps:
- uses: stackhero-io/github-actions-deploy-docker-containers-to-stackhero@v1
with:
# The secret STACKHERO_CERTIFICATES_PASSWORD and the variable STACKHERO_ENDPOINT should be defined in the corresponding branch environment on GitHub.
certificates_password: ${{ secrets.STACKHERO_CERTIFICATES_PASSWORD }}
endpoint: ${{ vars.STACKHERO_ENDPOINT }}
# deployment_command is optional. You can use it if you need to customize the Docker Compose command.
deployment_command: ${{ vars.STACKHERO_DEPLOY_COMMAND }}
You can commit your changes with:
git add -A .
git commit -m "Add GitHub Actions to deploy to Stackhero"
To create a production branch, you can run:
git checkout -b production
And then push your production branch to GitHub:
git push --set-upstream origin production
Once your code is pushed, GitHub Actions will automatically deploy it to your production Stackhero instance. You can monitor the deployment progress by checking the Actions tab in your GitHub project.
GitHub Actions that deployed to production
That is it. You are now set up to deploy your code to production automatically using GitHub Actions.