Continuous deployments with Changesets + GitHub actions

Photo by Chris Pagan on Unsplash

Changesets is an awesome tool for versioning NPM packages and maintaining changelogs for projects, it is quickly becoming a part of all our projects, public and private alike.

The Changesets GitHub action is designed to open a pull request with a running changelog then that PR is merged to do the release. This is great when you want to control when you release to NPM, but we want to simply release to NPM as soon as a pull request with a changeset is merged.

Setup

1. Create a personal access token

GitHub actions have the GITHUB_TOKEN secret, but that token will not trigger actions when it’s used.

We have a service account we have created which we generate personal access token (PAT) for and can use when we need to work with GitHub and trigger actions.

Once you have created a PAT save it as a GitHub secret for that repo, ours is called SERVICE_ACCOUNT_PAT

2. Create main workflow

The main workflow has 2 jobs

  1. version
  2. build

version will check if there are any unreleased packages, if there is it will version them and push to master, triggering a new build

build will only run if the version job had no unreleased changes

The below gist has been annotated with the various parts

This setup minimises the changes of git conflicts as the workflow which versions will run quickly and push the new commit as soon as possible.

3. That’s it

Your NPM packages will now release as soon as something is merged to master with a changeset.

Enjoy.

--

--

--

Co-Founder featureboard.app | Principal Consultant arkahna.io | Previously Tech Lead Seven West Media WA | International Speaker | OSS | Mentor

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Debugging Mobile Apps with mitmproxy

Alvin’s Dew Drop Daily — Issue #148

Daily UI Challenge — Countdown

Annotating a closure as running on the main thread

Certified Kubernetes Administrator Exam (CKA) Exam Preparation CheatSheet

Analytics as Code: Managing Analytics Solutions Like Any Other Software

Flutter | Firebase | Connect: Android, IOS & Web (2022)

ListView — Pagination And Reloading Network Calls In Flutter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jake Ginnivan

Jake Ginnivan

Co-Founder featureboard.app | Principal Consultant arkahna.io | Previously Tech Lead Seven West Media WA | International Speaker | OSS | Mentor

More from Medium

Auto Tagging and using Semantic Versioning with GitHub Actions

How to Get Employees from the Workday API with Python

Text that reads “Python Integration Tutorial / How to Get Employees from the Workday API”

Resiliency patterns for cloud-based applications — Part I

True Elasticity of Oracle Autonomous Database