Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Watch a Merge Go Live

Your deploy workflow is reviewed and its check is green. In this lesson, you merge it and watch GitHub turn that merge into a live site, without uploading a single file yourself. Do the two steps below first, then watch the video to see what happens after the merge.

Switch Pages to GitHub Actions and Merge

Your deploy pull request has a green check, and two steps stand between it and the store’s live site: a setting and the merge. GitHub Pages needs to know that a workflow will publish your site, so tell it first, before you merge:

  1. On your repository’s page on GitHub, open Settings, then Pages in the sidebar.

  2. Under Build and deployment, the Source menu says Deploy from a branch. Choose GitHub Actions instead. GitHub saves the choice right away.

Now open your pull request, “Deploy the site to GitHub Pages on every push to main”. If the merge button doesn’t already say Squash and merge, pick it from the button’s menu, keep the message GitHub fills in, and click Confirm squash and merge. Then click Delete branch.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

00:00 You’ve switched the store’s site to deploy from GitHub Actions, and you’ve clicked Squash and merge on your deploy pull request. The button turned purple, and then, well, it looks like not much happened at all.

00:13 So where’s the site? Quite a lot happens between that click and a live page, and it all starts with what the merge did to your main branch. Your branch had two commits, the new workflow and its formatting fix.

00:27 The squash merge squashes them into one new commit and puts it on main for you. To GitHub, that new commit arriving on main counts as a push to main, the same as if you’d pushed it from your laptop.

00:41 Your repository has two workflow files now, and the lines under on, near the top of each file, say when that workflow runs.

00:50 The check runs on pull requests into main, so it stays quiet this time. The deploy workflow runs on a push to main, and that’s exactly what the merge made.

01:00 So GitHub starts one run of the deploy workflow. On your repository’s Actions tab, a new row appears with the commit’s message and a yellow circle that says it’s in progress.

01:11 Yours may already show a green check, because the run finishes quickly. Open your run and compare it with this one.

01:19 On the run’s page, click the job called deploy to see its steps, named as they are in deploy.yml. GitHub runs them in order on a fresh Linux computer of its own.

01:29 It comes with common tools already installed, but none of your project’s files.

01:35 Checkout copies the commit’s files onto that computer. Set up Node gives it Node to run your tools with, and Install dependencies runs npm ci, which fills node_modules from your committed lockfile.

01:49 Build runs npm run build, and Vite writes the finished site into dist, with its five pages and an assets folder. The last three steps pack up dist as an artifact, a bundle the run keeps after its computer is gone, and hand it to GitHub Pages, which publishes it.

02:08 Each step turns green as it finishes. GitHub adds a few steps of its own around yours, such as Set up job at the start. Then the computer is thrown away. Your laptop didn’t build anything, and dist never went into your repository.

02:24 The whole run usually takes a minute or two, so the site doesn’t change the instant you merge.

02:30 Every merge takes this same path from now on. A merge is a push to main, a push to main starts one deploy run, and a green run puts the site live. Each green run publishes the commit that started it, and nobody uploads files by hand.

02:46 Now open your site. Back on the run’s summary, its address sits under the deploy job, with your own login at the start of it. If it doesn’t load yet, give it a moment and reload.

02:56 And there’s the store’s site, live on the internet. Well, sort of. The words are all there, but the colors and the layout are gone, and the opening hours are empty.

03:08 Don’t worry, the run did its job, and you haven’t broken anything.

03:13 Your merge went live on its own, from one click to the store’s address. The next lesson finds out why the page lost its styles and fixes it.

Become a Member to join the conversation.