You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### Authenticate and login to GitHub Container Registry using a PAT
115
+
#### Authenticate and login to GitHub Container Registry using GITHUB_TOKEN
116
116
117
-
Right now (in beta) [using the `GITHUB_TOKEN` to authenticate to the GHCR isn't possible](https://docs.github.com/en/packages/guides/pushing-and-pulling-docker-images#authenticating-to-github-container-registry). So we need to create a personal access token (PAT). But mind what the docs say:
117
+
From March 2021 on we should be able to use our `GITHUB_TOKEN` to authenticate against the GitHub Container Registry instead of using a separate PAT (see https://github.blog/changelog/2021-03-24-packages-container-registry-now-supports-github_token/)!
118
118
119
-
> PATs can grant broad access to your account. We recommend selecting only the necessary read, write, or delete package scope when creating a PAT to authenticate to the container registry. Avoid including the repo scope in a PAT used by a GitHub Actions workflow because it gives unnecessary additional access.
120
-
121
-
Here's the guide on how to create a PAT in Settings/Developer settings/Personal access tokens: https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token You need to select `read:packages`, `write:packages` and `delete:packages` scopes like this:
or Alternatively we can also use the [docker/login-action](https://github.com/docker/login-action) to to the login:
140
+
141
+
```yaml
142
+
- name: Login to GitHub Container Registry
143
+
uses: docker/login-action@v1
144
+
with:
145
+
registry: ghcr.io
146
+
username: ${{ github.actor }}
147
+
password: ${{ secrets.GITHUB_TOKEN }}
148
+
```
149
+
150
+
150
151
#### Publish (Push) Container image to GHCR
151
152
152
153
The final step now is to push our container image to the GitHub Container Registry. Therefore we need to tag our image correctly while building it using `ghcr.io/OWNER/IMAGE_NAME:latest`. After that we can push it:
0 commit comments