bake-action icon indicating copy to clipboard operation
bake-action copied to clipboard

ADD Cannot be Used to Add Public Git Repos Because The Action Fails With An Error

Open JLP04 opened this issue 5 months ago • 9 comments

Contributing guidelines

I've found a bug, and:

  • [x] The documentation does not mention anything about my problem
  • [x] There are no open or closed issues that are related to my problem

Description

When I try to build a Dockerfile with an ADD instruction pointing to a public Git repository using this action, I get the error fatal: could not read Username for 'https://gitlab.com/': terminal prompts disabled.

Expected behaviour

The action should properly be able to build the Dockerfile by executing the ADD command.

Actual behaviour

The action errors out with fatal: could not read Username for 'https://gitlab.com/': terminal prompts disabled.

Repository URL

https://github.com/JLP04/docker-elevation-generator

Workflow run URL

https://github.com/JLP04/docker-elevation-generator/actions/runs/17659617062

YAML workflow

name: ci-pr

on:
    push:
      branches:
        - main
    pull_request:

env: 
    IMAGE_NAME: ***/elevation-generator
    GITHUB_IMAGE_NAME: ghcr.io/***/elevation-generator

jobs:

    prepare:
        runs-on: ubuntu-latest
        outputs:
          matrix: ${{ steps.platforms.outputs.matrix }}
        steps:
            - name: Login to Docker Hub
              uses: docker/login-action@v3
              with:
                username: ${{ secrets.DOCKERHUB_USERNAME }}
                password: ${{ secrets.DOCKERHUB_PASSWORD }}

            - name: Login to GitHub Container Registry
              uses: docker/login-action@v3
              with:
                registry: ghcr.io
                username: ${{ github.repository_owner }}
                password: ${{ secrets.GITHUB_TOKEN }}

            - name: Set up QEMU
              uses: docker/setup-qemu-action@v3

            - name: Set up Docker Buildx
              uses: docker/setup-buildx-action@v3
              with:
                buildkitd-flags: --debug

            - name: Checkout Repo
              uses: actions/checkout@v5

            - name: Create matrix
              id: platforms
              run: |
                echo "matrix=$(docker buildx bake --print | jq -cr '.target."default".platforms')" >>${GITHUB_OUTPUT}

            - name: Show matrix
              run: |
                echo ${{ steps.platforms.outputs.matrix }}

            - name: Docker meta
              id: meta
              uses: docker/metadata-action@v5
              with:
                images: ${{ env.GITHUB_IMAGE_NAME }}
              
            - name: Rename meta bake definition file
              run: |
                mv "${{ steps.meta.outputs.bake-file }}" "${{ runner.temp }}/bake-meta.json"

            - name: Upload meta bake defintion
              uses: actions/upload-artifact@v4
              with:
                name: bake-meta
                path: ${{ runner.temp }}/bake-meta.json
                if-no-files-found: error
                retention-days: 1
    build:
        needs:
          - prepare
        strategy:
          fail-fast: false
          matrix:
            platform: ${{ fromJson(needs.prepare.outputs.matrix) }}
            include:
              - os: ubuntu-latest
              - os: ubuntu-24.04-arm
                platform: linux/arm/v5
              - os: ubuntu-24.04-arm
                platform: linux/arm/v7
              - os: ubuntu-24.04-arm
                platform: linux/arm64/v8
              - os: ubuntu-24.04-arm
                platform: linux/ppc64le
              - os: ubuntu-24.04-arm
                platform: linux/riscv64
              - os: ubuntu-24.04-arm
                platform: linux/s390x
        runs-on: ${{ matrix.os }}
        permissions:
          packages: write
        steps:
            - name: Free Up Space
              uses: jlumbroso/[email protected]
              with:
                tool-cache: true

            - name: Free Up More Space
              run: |
                sudo rm -rf /usr/local/share/powershell /usr/share/swift /usr/lib/jvm || true
                sudo apt autoremove -y
                sudo apt clean

            - name: Clean Old Package Config
              run: sudo apt purge -y '~c'

            - name: Prepare
              run: |
                platform=${{ matrix.platform }}
                echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV

            - name: Download meta bake definition
              uses: actions/download-artifact@v4
              with:
                name: bake-meta
                path: ${{ runner.temp }}

            - name: Login to Docker Hub
              uses: docker/login-action@v3
              with:
                username: ${{ secrets.DOCKERHUB_USERNAME }}
                password: ${{ secrets.DOCKERHUB_PASSWORD }}

            - name: Login to GitHub Container Registry
              uses: docker/login-action@v3
              with:
                registry: ghcr.io
                username: ${{ github.repository_owner }}
                password: ${{ secrets.GITHUB_TOKEN }}

            - name: Set up QEMU
              uses: docker/setup-qemu-action@v3

            - name: Set up Docker Buildx
              uses: docker/setup-buildx-action@v3
              with:
                buildkitd-flags: --debug

            - name: Checkout Repo
              uses: actions/checkout@v5

            - name: Get Git commit timestamps
              run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV

            - name: Get Git Indeterminate Branch
              run: echo "BRANCH_END=$(git ls-remote --heads "https://gitlab.com/flightgear/flightgear.git" | sed -nEe 's@.*[ \t]+refs/heads/release/([^ \t]+)@\1@p' | sort -t . -k 1,1n -k2,2n -k3,3n | tail -1 | tr -d '\n')" >> $GITHUB_ENV

            - name: Validate build configuration
              uses: docker/bake-action@v6
              with:
                targets: validate-build
                set: "default.args.branch_end=${{ env.BRANCH_END }}"
              env: 
                SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}

            - name: Build
              id: bake
              uses: docker/bake-action@v6
              with:
                files: |
                  ./docker-bake.hcl
                  cwd://${{ runner.temp }}/bake-meta.json
                targets: default
                set: |
                  default.args.branch_end=${{ env.BRANCH_END }}
                  default.tags=${{ env.GITHUB_IMAGE_NAME }}
                  *.platform=${{ matrix.platform }}
                  *.output=type=image,push-by-digest=true,name-canonical=true
                push: true
                provenance: true
                sbom: true
              env: 
                SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}

            - name: Export digest
              run: |
                mkdir -p ${{ runner.temp }}/digests
                digest="${{ fromJSON(steps.bake.outputs.metadata).default['containerimage.digest'] }}"
                touch "${{ runner.temp }}/digests/${digest#sha256:}"

            - name: Upload digest
              uses: actions/upload-artifact@v4
              with:
                name: digests-${{ env.PLATFORM_PAIR }}
                path: ${{ runner.temp }}/digests/*
                if-no-files-found: error
                retention-days: 1

    merge:
        runs-on: ubuntu-latest
        permissions:
          packages: write
        needs:
          - build
        steps:
          - name: Download meta bake definition
            uses: actions/download-artifact@v4
            with:
              name: bake-meta
              path: ${{ runner.temp }}

          - name: Download digests
            uses: actions/download-artifact@v4
            with:
              path: ${{ runner.temp }}/digests
              pattern: digests-*
              merge-multiple: true

          - name: Login to Docker Hub
            uses: docker/login-action@v3
            with:
              username: ${{ secrets.DOCKERHUB_USERNAME }}
              password: ${{ secrets.DOCKERHUB_PASSWORD }}

          - name: Login to GitHub Container Registry
            uses: docker/login-action@v3
            with:
              registry: ghcr.io
              username: ${{ github.repository_owner }}
              password: ${{ secrets.GITHUB_TOKEN }}

          - name: Set up QEMU
            uses: docker/setup-qemu-action@v3

          - name: Set up Docker Buildx
            uses: docker/setup-buildx-action@v3
            with:
              buildkitd-flags: --debug

          - name: Create manifest list and push
            working-directory: ${{ runner.temp }}/digests
            run: |
              docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.GITHUB_IMAGE_NAME }}")) | "-t " + .) | join(" ")' ${{ runner.temp }}/bake-meta.json) \
                $(printf '${{ env.GITHUB_IMAGE_NAME }}@sha256:%s ' *)

Workflow logs

logs_45309579880.zip

BuildKit logs

https://github.com/JLP04/docker-elevation-generator/actions/runs/17659617062/job/50190300250#step:19:2

https://github.com/JLP04/docker-elevation-generator/actions/runs/17659617062/job/50190320707#step:31:2

https://github.com/JLP04/docker-elevation-generator/actions/runs/17659617062/job/50190320661#step:31:2

https://github.com/JLP04/docker-elevation-generator/actions/runs/17659617062/job/50190320703#step:31:2

https://github.com/JLP04/docker-elevation-generator/actions/runs/17659617062/job/50190320695#step:31:2

https://github.com/JLP04/docker-elevation-generator/actions/runs/17659617062/job/50190320698#step:31:2

https://github.com/JLP04/docker-elevation-generator/actions/runs/17659617062/job/50190320726#step:31:2

https://github.com/JLP04/docker-elevation-generator/actions/runs/17659617062/job/50190320690#step:31:2

https://github.com/JLP04/docker-elevation-generator/actions/runs/17659617062/job/50190320705#step:31:2

Additional info

I'm aware this bug may not be fixable due to the nature of GitHub Actions but I figured I'd open a ticket in case it is.

JLP04 avatar Sep 11 '25 23:09 JLP04