Docker: Configure the GitHub Actions workflow
This documentation is part of the Deploy with GitHub Actions guide. You can view the complete guide here: Learn how to deploy your Docker containers using GitHub Actions.
Welcome to the Stackhero documentation
Stackhero offers 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 upcommand. No additional configuration required: just launch your containers.- Choose your own domain name, automatically secured with HTTPS (for example: https://api.your-company.com, https://www.your-company.com, or https://backoffice.your-company.com).
- Take advantage of high performance and enhanced security on private, dedicated infrastructure.
- Apply updates with a single click for simple, effortless maintenance.
Your containers can be running in production in about five minutes. Stackhero manages the infrastructure, updates, and security for you, so you can focus on developing your applications. Learn more about Docker CaaS cloud hosting.
On your local machine, go to your Git repository and create a directory named .github/workflows. In this directory, create a file called 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, run:
git checkout -b production
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 in the Actions tab of your GitHub project.
GitHub Actions that deployed to production
That's it. Your setup is now ready to automatically deploy your code to production using GitHub Actions.