docs/versioned_docs/version-0.20.2/getting-started/ci-integrations/github-actions.mdx
Dagger provides a GitHub Action that can be used in any GitHub Actions workflow to call one or more Dagger Functions on specific events, such as a new commit.
Dagger has also partnered with Depot to provide managed, Dagger Powered GitHub Actions runners. These runners, which serve as drop-in replacements for GitHub's own runners, come with Dagger pre-installed and pre-configured to best practices, automatic persistent layer caching, and multi-architecture support. They make it faster and easier to run Dagger pipelines in GitHub repositories.
Depending on whether you choose a standard GitHub Actions runner or a Dagger Powered Depot GitHub Actions Runner, here's how it works.
<Tabs groupId="runner"> <TabItem value="GitHub">When running a CI pipeline with Dagger using a standard GitHub Actions runner, the general workflow looks like this:
DAGGER_CLOUD_TOKEN environment variable is set.When running a CI pipeline on a Dagger Powered Depot GitHub Actions Runner, the general workflow looks like this:
The following example demonstrates how to call a Dagger Function on a standard GitHub runner in a GitHub Actions workflow.
You can also use Dagger shell syntax instead of Dagger call syntax in your Github Actions workflow. This is useful if you want to use the more advanced chaining and subshell capabilities of Dagger shell.
The following is a more complex example demonstrating how to create a GitHub Actions workflow that checks out source code, calls a Dagger Function to test the project, and then calls another Dagger Function to build and publish a container image of the project. This example uses a simple Go application and assumes that you have already forked it in your own GitHub repository.
More information is available in the Dagger for GitHub page.
</TabItem> <TabItem value="Depot">The following example demonstrates how to call a Dagger Function on a Dagger Powered Depot runner in a GitHub Actions workflow. The runs-on clause specifies the runner and Dagger versions.
You can also use Dagger shell syntax instead of Dagger call syntax in your Github Actions workflow. This is useful if you want to use the more advanced chaining and subshell capabilities of Dagger shell.
The following is a more complex example demonstrating how to create a GitHub Actions workflow that checks out source code, calls a Dagger Function to test the project, and then calls another Dagger Function to build and publish a container image of the project. This example uses a simple Go application and assumes that you have already forked it in your own GitHub repository.
:::warning
Always ensure that the same Dagger versions are specified in the runs-on and version clauses of the workflow definition.
:::
More information is available in the Dagger for GitHub page and in the Depot documentation.
</TabItem> </Tabs>When using SSH keys in GitHub Actions, ensure proper SSH agent setup:
- name: Set up SSH
run: |
eval "$(ssh-agent -s)"
ssh-add - <<< '${{ secrets.SSH_PRIVATE_KEY }}'
Replace ${{ secrets.SSH_PRIVATE_KEY }} with your provider secret containing the private key.
Below are some resources from the Dagger community that may help as well. If you have any questions about additional ways to use GitHub with Dagger, join our Discord and ask your questions in our GitHub channel.
GitHub is a popular Web-based platform used for version control and collaboration. It allows developers to store and manage their code in repositories, track changes over time, and collaborate with other developers on projects.
Depot is a build acceleration platform focused on making builds more efficient and performant.