I am trying to build a CI pipeline that will build the image and push it to the repository. This is how the pipeline currently looks:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: check ENV
run: env
- name: Build the Docker image
run: docker build . --file Dockerfile --tag ${{ github.reponame }}:${{ github.run_number }} --build-arg DB_PASSWORD="${{ secrets.DB_PASSWORD }}"
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ github.reponame }}:${{ github.run_number }}
When I'm running the job it fails on the "Build and push" job, this is the error message:
Error: buildx failed with: ERROR: unauthorized: access token has insufficient scopes
I tried to re-create the token and make sure that it has privileges (currently allowed r/w/d) and all of the other environment variables as well.
Try something like this:
Use repository secrets,
DOCKERHUB_USERNAMEandDOCKERHUB_PASSWORD, to store your Docker Hub credentials.The
docker/build-push-actionaction will build your image too, so there is no need to have a separate build step.You can find more information on this here.