Demonstrates how a simple workflow with no additional configuration/passwords/tokens is sufficient to publish Docker images to GitHub Container Registry.
Based primarily on the official instrutions which are likely more up-to-date.
- Ensure that you have a
Dockerfile
in the root of the repo, and a workflow file that has been pushed to GitHub. - The provided workflow is triggered only by "workflow dispatch". To start a build:
- Go to the main page of your repo.
- Click on the "Actions" tab
- Select "Build Docker image and publish to GHCR" on the left
- Click the grey "Run workflow" button
- With the desired branch selected, click the green "Run workflow" button.
The workflow is extremely basic so you will probably want to adapt it to your needs. The following suggestions are beyond the scope of this simple demonstration:
- Add other build triggers besides "workflow dispatch" by modifying the
on
section. - Customize the name of the image. (Currently it's the repo name with
-image
as a suffix.) - Generate tags and other metadata with docker/metadata-action
- Enable caching of build layers.
- Set up QEMU if you want to build images for other architectures.
- Test the image before pushing it.
- Push conditionally only on release or tag events, but still build and test on every push.