This is a template for deploying Portainer stacks with GitHub Actions.
Note: Using Portainer webhooks requires Portainer Business Edition. You can get a free license here.
- 🐋 GitHub Actions workflow to build and push the image to whatever registry you want (defaults to
ghcr.io
) - 🪝 Webhook to automatically update the stack on Portainer
- Download the
deploy.yml
and move it to the.github/workflows
folder:
curl -LJO https://raw.githubusercontent.com/inputstudio/portainer-stack-template/main/.github/workflows/deploy.yml
If you don't have curl
installed, you can open the link above and copy the content to a new file named deploy.yml
in the .github/workflows
folder.
-
Edit
deploy.yml
replacingghcr.io/inputstudio/hello-world
with your image name. -
Create your
Dockerfile
andcompose.yml
or use docker init:
docker init
- (optional) If you want to use environment variables in your stack, add the following to your
compose.yml
:
services:
my-service:
env_file:
- stack.env # This file contains all the environment variables set in the stack editor
- Add a stack on Portainer and enable GitOps webhook.
- Add the webhook URL to your GitHub repo secrets as
PORTAINER_STACK_WEBHOOK
. - Done 🎉