Portainer Documentation
website·Indexed 32 days ago
https://portainer-deploy.cssnr.comDocumentation for Portainer, including guides on relative path support and the Portainer Stack Deploy Action for GitHub Actions, detailing input parameters such as name, url, token, and prune.
What's inside Portainer
- GitHub organizations are shared accounts that act as containers for shared work, providing a unique name and brand for businesses or open-source projects. They allow multiple personal accounts to collaborate on projects. Access is managed by organization owners who can assign roles to members to control access to the organization's resources, repositories, projects, and apps. To simplify management, organizations support nested teams with cascading permissions.
Understand GitHub Actions workflow basics
A GitHub Actions workflow is a configurable automated process defined by a YAML file located in the
.github/workflowsdirectory of a repository. A workflow consists of three primary components:- Events: Triggers that start the workflow.
- Jobs: Execution units that run on a runner machine. Each job contains one or more steps.
- Steps: Individual tasks within a job that either execute a custom script or a reusable action.
Set up a basic Portainer deployment workflow
To deploy a stack to Portainer, create a workflow file in.github/workflows. Ensure that sensitive credentials like the Portainer token are stored in GitHub Actions Secrets to prevent them from appearing in logs.Create organization-level secrets in GitHub
To create secrets for an organization:
- Navigate to the main page of the organization on GitHub.
- Click Settings (if not visible, use the kebab menu dropdown).
- In the sidebar under the "Security" section, select Secrets and variables > Actions.
- Manage secrets and their associated permissions/policies from the list.
View workflow run logs to diagnose failures
When a GitHub Actions workflow run fails, you can identify the specific failed step and review its build logs. GitHub automatically expands failed steps in the log view. You can also copy a permalink to a specific line in the log file by clicking the line number.
Note that every job includes two automatic steps: 'Set up job' (which records runner image details and preinstalled tools for GitHub-hosted runners) and 'Complete job'.
Steps to view logs:
- Navigate to the repository main page and click the Actions tab.
- Select the specific workflow from the left sidebar.
- Click the name of the specific workflow run to see the summary.
- Click the desired job under Jobs or within the visualization graph.
- Review the expanded failed steps.
Download workflow run log archives
You can download the complete log files for a workflow job as an archive. Read access to the repository is required.
Steps to download logs:
- Navigate to the repository main page and click the Actions tab.
- Select the workflow from the left sidebar.
- Click the name of the workflow run to see the summary.
- Click the job you wish to download logs for.
- Click the gear icon (options menu) in the upper-right corner of the log view.
- Select Download log archive.
Use secrets in a GitHub Actions workflow
Access secrets using the
secretscontext. Secrets can be passed as action inputs or as environment variables. If a secret is not set, the expression returns an empty string.Important Constraints:
- Secrets (except
GITHUB_TOKEN) are not passed to runners when a workflow is triggered from a forked repository. - Secrets are not automatically passed to reusable workflows.
- Secrets are not available to workflows triggered by Dependabot events.
- Secrets cannot be directly referenced in
if:conditionals; instead, set them as job-level environment variables and reference those variables in the conditional.
steps: - name: Hello world action with: # Set the secret as an input super_secret: ${{ secrets.SuperSecret }} env: # Or as an environment variable super_secret: ${{ secrets.SuperSecret }}- Secrets (except
Delete workflow run logs via the GitHub web interface
To delete logs for a specific workflow run using the browser, you must have write access to the repository. Navigate to the repository's Actions tab, select the specific workflow from the sidebar, click on the name of the desired run to open the summary, and select Delete all logs from the kebab (three-dot) menu in the upper-right corner.Pass secrets to shell commands securely
Avoid passing secrets directly as command-line arguments to prevent them from being visible in process lists (e.g.,pscommand) or security audits. Instead, map the secret to an environment variable and reference that variable using the shell's specific quoting rules to handle special characters.# Bash example steps: - shell: bash env: SUPER_SECRET: ${{ secrets.SuperSecret }} run: | example-command "$SUPER_SECRET" # PowerShell example steps: - shell: pwsh env: SUPER_SECRET: ${{ secrets.SuperSecret }} run: | example-command "$env:SUPER_SECRET" # Cmd.exe example steps: - shell: cmd env: SUPER_SECRET: ${{ secrets.SuperSecret }} run: | example-command "%SUPER_SECRET%"Search for specific terms in workflow run logs
You can search for specific text within the build logs of a workflow job. Note that the search only includes logs from steps that are currently expanded in the UI. Read access to the repository is required.
Steps to search logs:
- Navigate to the repository main page and click the Actions tab.
- Select the workflow from the left sidebar.
- Click the name of the workflow run to see the summary.
- Click the job you wish to inspect.
- Use the Search logs search box in the upper-right corner of the log output to enter your query.
Connect Portainer to GitHub Container Registry (GHCR)
To allow Portainer to pull private images from GHCR, you must add GHCR as a custom registry in the Portainer UI using a GitHub Personal Access Token (PAT).Configure the following in Portainer > Registries > + Add registry:
Key Value Description Name ghcr.ioDisplay name Registry URL ghcr.ioAuthentication URL Authentication TrueEnable credentials Username usernameGitHub Username Password PATGitHub Personal Access Token Use relative path volumes for Git-based stacks in Portainer
Relative path volumes allow you to reference files and directories stored within a Git repository alongside your compose file without knowing the absolute path on the host. This feature is exclusive to Portainer Business Edition and must be enabled during stack deployment from Git.
When enabled, Portainer clones the Git repository to a specified local or network filesystem path and sets the working directory to the location of the compose file. This allows the use of relative paths (starting with
./or../) in thevolumessection of the docker-compose file.version: '3.1' services: webapp: image: nginx:latest volumes: - ./static:/usr/share/nginx/html # Relative to the compose file