Continuous Deployment (CD) is the process of automatically deploying code changes to a production environment after the code has been built and tested. Let’s set up CD for Notely!

We’ll be using GitHub Actions again, but we’ll create a new workflow for CD: cd.yml

How to create cd#

  1. Create a new workflow .github/workflows/cd.yml
  2. It should trigger on push into the main branch.
on:
  push:
    branches: [main]
  1. It should have a single job called Deploy
  2. It should checkout the code
  3. It should set up the Go toolchain
  4. It should build the app using the scripts/buildprod.sh script

To be clear, the ci workflow runs when a pull request is opened, but the cd workflow runs when a pull request is merged (or when code is pushed directly to the main branch).

Run the cd workflow and ensure it works by merging your PR into main (or pushing directly to main).

Paste the URL of your GitHub repo into the box and run the GitHub checks.

name: cd

on:
  push:
    branches: [main]

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest

    steps:
      - name: Check out code
        uses: actions/checkout@v4

      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: "1.26.0"

      - name: Build app
        run: ./scripts/buildprod.sh