Skip to content

Instantly share code, notes, and snippets.

@garnajee
Forked from yokawasa/ghcr.md
Last active May 20, 2024 12:24
Show Gist options
  • Save garnajee/873cc26389cb21d07b19c2dd8150b2f0 to your computer and use it in GitHub Desktop.
Save garnajee/873cc26389cb21d07b19c2dd8150b2f0 to your computer and use it in GitHub Desktop.

Revisions

  1. garnajee revised this gist May 20, 2024. 1 changed file with 12 additions and 5 deletions.
    17 changes: 12 additions & 5 deletions ghcr.md
    Original file line number Diff line number Diff line change
    @@ -5,26 +5,33 @@
    To push container images to ghcr, you need peronal access token (PAT) - see [how to create PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)

    1. Get PAT (personal access token)
    2. use thess permissions: `repo, write:packages`
    3. export PAT: `export CR_PAT=YOUR_TOKEN`

    Personal Settings > Developer settings > [Personal access tokens](https://github.com/settings/tokens)

    2. ghcr login test
    ```bash
    # echo $PAT | docker login ghcr.io -u <githubユーザ名> --password-stdin
    echo $PAT | docker login ghcr.io -u yokawasa --password-stdin
    echo $CR_PAT | docker login ghcr.io -u garnajee --password-stdin

    Login Succeeded
    ```

    3. build

    ```bash
    docker build -t ghcr.io/garnajee/myrepo/mycontainer:0.0.1 .
    ```

    3. push
    ```bash
    docker tag mycontainer ghcr.io/yokawasa/myrepo/mycontainer:0.0.1
    docker push ghcr.io/yokawasa/myrepo/mycontainer:0.0.1
    # docker tag mycontainer ghcr.io/yokawasa/myrepo/mycontainer:0.0.1
    docker push ghcr.io/garnajee/myrepo/mycontainer:0.0.1
    ```
    4. inspect

    ```bash
    docker inspect ghcr.io/yokawasa/myrepo/mycontainer:0.0.1
    docker inspect ghcr.io/garnajee/myrepo/mycontainer:0.0.1
    ```

    ## GitHub Actions
  2. @yokawasa yokawasa revised this gist Jan 17, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions ghcr.md
    Original file line number Diff line number Diff line change
    @@ -43,6 +43,9 @@ you can do seamless access to containers from Actions workflows via the `GITHUB_
    See [Upgrading a workflow that accesses ghcr.io](https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio) for more detail
    ## Associate a certain package to a repository
    - [Connecting a repository to a package](https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package)
    ## REFERENCES
    - https://github.com/features/packages
  3. @yokawasa yokawasa revised this gist Dec 1, 2021. 1 changed file with 25 additions and 3 deletions.
    28 changes: 25 additions & 3 deletions ghcr.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # ghcr (GitHub Container Registry) quickstart

    ## Setup GHCR
    ## CLI

    To push container images to ghcr, you need peronal access token (PAT) - see [how to create PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)

    @@ -21,7 +21,29 @@ Login Succeeded
    docker tag mycontainer ghcr.io/yokawasa/myrepo/mycontainer:0.0.1
    docker push ghcr.io/yokawasa/myrepo/mycontainer:0.0.1
    ```
    4. inspect

    ```bash
    docker inspect ghcr.io/yokawasa/myrepo/mycontainer:0.0.1
    ```

    ## GitHub Actions

    you can do seamless access to containers from Actions workflows via the `GITHUB_TOKEN`

    > The Container registry supports the GITHUB_TOKEN for easy and secure authentication in your workflows. If your workflow is using a personal access token (PAT) to authenticate to ghcr.io, then we highly recommend you update your workflow to use the GITHUB_TOKEN.

    ```yaml
    - name: Log in to registry
    # This is where you will update the PAT to GITHUB_TOKEN
    run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
    ```
    See [Upgrading a workflow that accesses ghcr.io](https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio) for more detail
    REFERENCES
    - https://github.com/features/packages
    ## REFERENCES
    - https://github.com/features/packages
    - [Upgrading a workflow that accesses ghcr.io](https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio)
  4. @yokawasa yokawasa revised this gist Oct 3, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions ghcr.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@

    ## Setup GHCR

    To push container images to ghcr, you need peronal access token (PAT) - see [how to create PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)

    1. Get PAT (personal access token)

    Personal Settings > Developer settings > [Personal access tokens](https://github.com/settings/tokens)
  5. @yokawasa yokawasa revised this gist Oct 3, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ghcr.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Tips on GHCR (GitHub Container Registry)
    # ghcr (GitHub Container Registry) quickstart

    ## Setup GHCR

  6. @yokawasa yokawasa renamed this gist Oct 3, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. @yokawasa yokawasa created this gist Oct 3, 2021.
    25 changes: 25 additions & 0 deletions ghcr-tips.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    # Tips on GHCR (GitHub Container Registry)

    ## Setup GHCR

    1. Get PAT (personal access token)

    Personal Settings > Developer settings > [Personal access tokens](https://github.com/settings/tokens)

    2. ghcr login test
    ```bash
    # echo $PAT | docker login ghcr.io -u <githubユーザ名> --password-stdin
    echo $PAT | docker login ghcr.io -u yokawasa --password-stdin

    Login Succeeded
    ```

    3. push
    ```bash
    docker tag mycontainer ghcr.io/yokawasa/myrepo/mycontainer:0.0.1
    docker push ghcr.io/yokawasa/myrepo/mycontainer:0.0.1
    ```


    REFERENCES
    - https://github.com/features/packages