I'm following the testdriven.io course Test-Driven Development with FastAPI and Docker
I'm at the end of the Continuous integration chapter, I just pushed a pull request with all the GitHub actions, and it fails.
My errors from GitHub actions:
Here are my settings for a personal access token:
I tried different things to make it work from extending the access token scopes to replacing docker.pkg.github.com with ghcr.io as mentioned by Github, without success.
I managed to solve the problem, but I am unfamiliar with DevOps, CI/CD, GithHub actions, and Docker registries. Therefore, everything that follows should be treated cautiously.
After the "GitHub to login packages" step in the .github/workflows/main.yml, add this step:
- name: Login to Docker registry
uses: docker/login-action@v2
with:
registry: docker.pkg.github.com
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_TOKEN }}
Create a repository secret DOCKER_TOKEN, and paste your docker token.
Go to your Docker account page and click on the "Security" tab to access your Docker token. From there, you can navigate to the "Access tokens" section, where you should see a list of your existing tokens.
If you don't have any existing tokens, you can create a new one by clicking on the "New Access Token" button and following the prompts. Once you have your token, you can authenticate with Docker and access private images.
To authorize your token, click on the "Authorize" button next to the token in the list of access tokens. This will grant the token permission to access the resources it needs to pull the desired Docker image.