Deployment Automation with GitHub Actions and Nitric
This guide will demonstrate how Nitric can be used, along with GitHub Actions, to create a continuous deployment pipeline. We provide examples for deploying to AWS, Google Cloud, and Microsoft Azure, which you can adapt based on your preferred cloud provider.
This guide assumes basic knowledge about GitHub Actions. If you're new to the feature you could start by reviewing GitHub's docs
Configuration
-
Prepare Your Nitric Project
Ensure you have a Nitric project ready to deploy. If you haven’t set up a project yet, refer to our quickstart guide. -
Add a GitHub Actions Workflow File
Create a YAML file in a.github/
folder at the root of your project to configure the deployment automation steps. You can name the file according to your preference; for our examples, we usedeploy-aws.yaml
,deploy-azure.yaml
, anddeploy-gcp.yaml
.
Here’s example content for each cloud provider:
name: Example Nitric AWS Deployment# Triggers for the workflowon:# Allows manual triggering of the workflow from GitHubworkflow_dispatch:# Triggers the workflow on push to the main branchpush:branches:- mainjobs:update:# The workflow will run on the latest Ubuntu OSruns-on: ubuntu-lateststeps:# Check out the code from the repository- name: Checkout 🛎️uses: actions/checkout@v4# Install Pulumi for infrastructure management# Learn more about the Pulumi action configuration at https://github.com/pulumi/actions.- name: Install and configure Pulumi 📦uses: pulumi/actions@v4# Apply infrastructure using Nitric# Learn more about the Nitric action configuration at https://github.com/nitrictech/actions.- name: Applying infrastructure 🚀uses: nitrictech/actions@v1with:# The 'up' command deploys the projectcommand: up# Replace with your stack namestack-name: devenv:# Configure the environment variables required by Nitric's dependency Pulumi and AWS.# In this example, we store the required values in GitHub secrets. Secrets can be found by navigating to:# https://github.com/{user}/{project}/settings/secrets/actions# Pulumi config passphrase# For interaction-free experiences, Pulumi requires a passphrase. Your passphrase generates a unique key that encrypts configuration and state values.PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}# Pulumi access token# You can get a Pulumi access token by logging into Pulumi on the browser and going to your profile settings. Under the 'Access Tokens' tab, click 'Create token.'PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}# AWS access key ID# You can obtain a key ID from the AWS console: https://console.aws.amazon.com/AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}# AWS secret access key# You can obtain an access key from the AWS console: https://console.aws.amazon.com/AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}