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#
- Create a new workflow
.github/workflows/cd.yml - It should trigger on
pushinto themainbranch.
on:
push:
branches: [main]- It should have a single job called
Deploy - It should checkout the code
- It should set up the Go toolchain
- It should build the app using the
scripts/buildprod.shscript
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