1
0
mirror of synced 2025-12-22 11:26:57 -05:00

Update migrating-to-github-container-registry-for-docker-images.md (#5886)

* Update migrating-to-github-container-registry-for-docker-images.md

This commit solves #5020. By preferring the use of the GITHUB_TOKEN instead of CR_PAT.

* Fix reusable

* Update container registry docs

This commit makes the migrating-to-github-container-registry-for-docker-images.md more descriptive about using the Github Token for workflow authentication.

Co-authored-by: hubwriter <hubwriter@github.com>

Co-authored-by: Jessica Canepa <jmarlena@github.com>
Co-authored-by: hubwriter <hubwriter@github.com>
This commit is contained in:
Dan Bamikiya
2021-05-18 10:31:46 +01:00
committed by GitHub
parent de6e8b14ad
commit bec311d383

View File

@@ -95,9 +95,9 @@ If you have a {% data variables.product.prodname_actions %} workflow that uses a
2. In your {% data variables.product.prodname_actions %} workflow file, update the package url from `https://docker.pkg.github.com` to `ghcr.io`. 2. In your {% data variables.product.prodname_actions %} workflow file, update the package url from `https://docker.pkg.github.com` to `ghcr.io`.
3. Add your new {% data variables.product.prodname_container_registry %} authentication personal access token (PAT) as a GitHub Actions secret. The {% data variables.product.prodname_container_registry %} does not support using `GITHUB_TOKEN` for your PAT so you must use a different custom variable, such as `CR_PAT`. For more information, see "[Creating and storing encrypted secrets](/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets)." 3. Use the `GITHUB_TOKEN` for your authentication personal access token (PAT). For more information, see "[Authentication in a workflow](/actions/reference/authentication-in-a-workflow)."
4. In your {% data variables.product.prodname_actions %} workflow file, update the authentication PAT by replacing your Docker registry PAT ({% raw %}`${{ secrets.GITHUB_TOKEN }}`{% endraw %}) with a new variable for your {% data variables.product.prodname_container_registry %} PAT, such as {% raw %}`${{ secrets.CR_PAT }}`{% endraw %}. 4. In your {% data variables.product.prodname_actions %} workflow file, use the authentication token {% raw %}`${{ secrets.GITHUB_TOKEN }}`{% endraw %} as your {% data variables.product.prodname_container_registry %} PAT.
#### Example of updated workflow #### Example of updated workflow
@@ -112,12 +112,12 @@ docker push docker.pkg.github.com/github/octoshift/octoshift:$GITHUB_SHA
``` ```
{% endraw %} {% endraw %}
Then you'll need to update your workflow with the new {% data variables.product.prodname_container_registry %} URL and PAT like this: Then you'll need to update your workflow with the new {% data variables.product.prodname_container_registry %} URL like this:
{% raw %} {% raw %}
```yaml ```yaml
# new login with new container registry url and PAT # new login with new container registry url and PAT
echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
# new container registry urls added # new container registry urls added
docker pull ghcr.io/github/octoshift:latest docker pull ghcr.io/github/octoshift:latest
docker build . --tag ghcr.io/github/octoshift:$GITHUB_SHA --cache-from ghcr.io/github/octoshift:latest docker build . --tag ghcr.io/github/octoshift:$GITHUB_SHA --cache-from ghcr.io/github/octoshift:latest