How to: Use the Dapr CLI in a GitHub Actions workflow

Add the Dapr CLI to your GitHub Actions to deploy and manage Dapr in your environments.

Dapr can be integrated with GitHub Actions via the Dapr tool installer available in the GitHub Marketplace. This installer adds the Dapr CLI to your workflow, allowing you to deploy, manage, and upgrade Dapr across your environments.

Install the Dapr CLI via the Dapr tool installer

Copy and paste the following installer snippet into your application’s YAML file:

  1. - name: Dapr tool installer
  2. uses: dapr/setup-dapr@v1

The dapr/setup-dapr action will install the specified version of the Dapr CLI on macOS, Linux, and Windows runners. Once installed, you can run any Dapr CLI command to manage your Dapr environments.

Refer to the action.yml metadata file for details about all the inputs.

Example

For example, for an application using the Dapr extention for Azure Kubernetes Service (AKS), your application YAML will look like the following:

  1. - name: Install Dapr
  2. uses: dapr/setup-dapr@v1
  3. with:
  4. version: '1.13.0'
  5. - name: Initialize Dapr
  6. shell: bash
  7. run: |
  8. # Get the credentials to K8s to use with dapr init
  9. az aks get-credentials --resource-group ${{ env.RG_NAME }} --name "${{ steps.azure-deployment.outputs.aksName }}"
  10. # Initialize Dapr
  11. # Group the Dapr init logs so these lines can be collapsed.
  12. echo "::group::Initialize Dapr"
  13. dapr init --kubernetes --wait --runtime-version ${{ env.DAPR_VERSION }}
  14. echo "::endgroup::"
  15. dapr status --kubernetes
  16. working-directory: ./demos/demo3

Next steps

Last modified March 21, 2024: Merge pull request #4082 from newbe36524/v1.13 (f4b0938)