GitHub Container Registry
GitHub Container Registry supersedes the existing Packages Docker Registry and is optimized to support some of the unique needs of containers. If you've used the GitHub Packages Docker Registry to store Docker images, you can migrate to the new container registry.
With the container registry you can:
- Store container images within your organization and user account, rather than a repository.
- Set fine-grained permissions and visibility independent of repository permissions and visibility.
- Access public container images anonymously.
Note: This chapter is only applicable if you push images to GitHub Container Registry.
CI command
You'll need to pass in the -p
flag when pinging FeaturePeek in your CI pipeline.
Be sure to call this after your build step.
Enable GitHub Container Registry for your organization
In an organization, organization admins can allow organization members to publish public or private container images to GitHub Container Registry.
Follow the instructions in GitHub's help docs to set whether you'd like your packages to be public or private.
Assign a personal access token (PAT)
Creating the PAT
To give your CI pipeline permission to push Docker images to GitHub Container Registry, you need to create a personal access token. This token should only be granted the write:packages
and read:packages
scopes.
- Go to your Personal access tokens settings page
- Click the "Generate new token" button
- In the Note field, type in
GHCR
or similar so that you'll remember that this token is for the GitHub Container Registry. - Select the
write:packages
andread:packages
checkboxes. You may deselect therepo
checkbox if it automatically becomes selected. - Click the green "Generate token" button at the bottom of the page
- Copy the token on the resulting page
Using the PAT as a repository secret
- Go to your repo's settings page on GitHub
- In the left-hand column, click Secrets
- Click the "New secret" button
- For name, enter the value
CR_PAT
(this stands for Container Registry Personal Access Token) - For value, paste the token that you copied when you created your PAT
- Click "Add secret"
Required environment variables
CR_PAT
Below is an example workflow YAML file that builds a docker image and pushes it to the GitHub Packages registry. Be sure to replace ORG
and REPO
with your own values.
The last line in the following example is how you set an environment variable to a secret.