Edward Thomson

This is day 9 of my GitHub Actions Advent Calendar. If you want to see the whole list of tips as they're published, see the index.

So far this month, we've looked at a lot of scenarios that perform a build and then run some tests. And these are great workflows – they ensure that pull requests coming in to your project are high quality and that your master branch is healthy.

But you often want to take the next step and deploy something that you build. For example, you might want to build a container and upload it to GitHub Packages every time something new lands in the master branch. This will make sure you have a container that you can run and validate for every change.

To do that, we'll want to trigger on pushes into master. (The push trigger will run for any integration into master, whether it's from a literal git push or from a merge of a pull request.)

Then we'll log in to GitHub Packages from docker. We can simply use the GITHUB_TOKEN that's provided to us from GitHub Actions - the token has publish permissions to the packages in our repository.

Then we'll build our container, tagging it with the name of the package registry (in this case, docker.pkg.github.com followed by the name of my container, ethomson/myrepo/app), and giving it a version number that is the Unix time.

Finally, we'll push the container up to GitHub Packages.

Now I have a simple continuous deployment system that will always update GitHub Packages with the container that always contains the latest build from my master branch.