Code Monkey home page Code Monkey logo

Comments (2)

ThomasVitale avatar ThomasVitale commented on July 30, 2024 1

@nmuianga when using the ${{ secrets.GITHUB_TOKEN }} placeholder, GitHub automatically injects a short-lived token configured with permissions that depend on what is configured in the workflow. The job in a workflow that is responsible for publishing images must declare the packages: write permission as follows.

package:
    name: Package and Publish
    runs-on: ubuntu-22.04
    permissions:
      contents: read
      packages: write
      security-events: write

The examples in the book follow this setup for publishing images having the following format: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}. In particular, REGISTRY must be equal to ghcr.io and IMAGE_NAME must be exactly the same as the repository name. The GitHub Actions workflows in the book don't need you to create custom Personal Access Tokens since the token automatically provided by GitHub is enough.

There might be reason for which you can't use the automatically provided token. For example, if you need IMAGE_NAME to be something else than the repository name, but you still want to publish to the GitHub Container Registry (ghcr.io), then you can create a Personal Access Token as described in the book. That token needs the write:packages scope. Is this your use case?

Screenshot 2023-12-16 at 14 35 39

You can then save the value of the newly generated token into a Secret in your GitHub repository. Since GITHUB_TOKEN is the name of the token automatically injected by GitHub, your custom token should have a different name to avoid conflicts. Could this be the reason for the error you experienced? In the snippet you shared, I can see that ${{ secrets.GITHUB_TOKEN }} is used. If you want to use your Personal Access Token (let's say you saved it as a Secret with name MY_CUSTOM_TOKEN) , then the value passed to the Docker Login action should be ${{ secrets.MY_CUSTOM_TOKEN }}.

from cloud-native-spring-in-action.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.