It's pretty straight forward to build and push your container images to OpenRegistry. Let's take a look at two (out of many) ways to push your container images to OpenRegistry, everytime you push to main branch.
Github Marketplace is full of Actions that let's you build/push container images. One such Action is Publish-Docker-Github-Action
To set this Github Action on your repository, create a file under .github/workflows/push-to-openregistry.yaml
and add the following contents inside it:
Now that our workflow file is setup, let's add some Github Secrets. Navigate to Repository Settings -> Secrets -> Actions -> New Repository Secret
Name: OPEN_REGISTRY_USERNAME and Value: johndoe
Name: OPEN_REGISTRY_PASSWORD and Value: Super-Secret-Password
Congratulations, you've added a Github Action to your repository and now everytime you push to "main" branch, it will build and push the image to OpenRegistry.
Now's it's possible that you don't want to use a third party Github Action to push your container images and that's a fine thought. Let's do this by ourselves.
We're going to start with the same first step, create a file under .github/workflows/push-to-openregistry.yaml
and add the following contents inside it: