docs/current_docs/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.
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.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.
Instead of spinning up a Dagger Engine inside the GitHub Actions runner, you can offload execution to a managed Dagger Engine provided by Dagger Cloud. This gives you persistent caching and additional compute capacity without provisioning your own infrastructure.
To use a Dagger Cloud Engine from a GitHub Actions workflow:
In Dagger Cloud, navigate to the settings page using the cogwheel icon in the top navigation bar and open the Tokens sub-menu (the same location as the Telemetry token). Copy the Compute Token. You can also use this URL pattern: https://dagger.cloud/{Your Org Name}/settings?tab=Tokens.
In your GitHub repository, go to Settings > Secrets and variables > Actions and click New repository secret. Name it DAGGER_CLOUD_TOKEN and paste the Compute Token as the value.
In your workflow, set dagger-flags: "--cloud" on the dagger/dagger-for-github step. The Dagger CLI will then connect to a Dagger Engine provided by Dagger Cloud instead of starting one inside the runner.
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.
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.