Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot push to Github Container Registry #15

Open
geeanlooca opened this issue Mar 28, 2022 · 7 comments
Open

Cannot push to Github Container Registry #15

geeanlooca opened this issue Mar 28, 2022 · 7 comments

Comments

@geeanlooca
Copy link

Hi, I'm trying to build a Singularity and push it to Github Container Registry using one of the Github Actions workflow provided in this repo as a template.

I run a modified version of the "Docker" workflow, where I skip the step that checks whether the Singularity recipe has been changed in order to build the image at every push. Here is the content of the .yaml file for this workflow.

name: Singularity Build (docker)
on: 
  push:

    # Edit the branches here if you want to change deploy behavior
    branches:
      - main
      - master

  # Do the builds on all pull requests (to test them)
  # pull_request: []

jobs:
  build-test-containers:
    runs-on: ubuntu-latest
    strategy:
      # Keep going on other deployments if anything bloops
      fail-fast: false
      matrix:
        singularity_version:
        - '3.8.1'
        recipe: ["Singularity"]


    container:
      image: quay.io/singularity/singularity:v${{ matrix.singularity_version }}
      options: --privileged

    name: Check ${{ matrix.recipe }}
    steps:

      - name: Check out code for the container builds
        uses: actions/checkout@v2

      - name: Continue if Singularity Recipe Exists
        run: |
          if [[ -f "${{ matrix.recipe }}" ]]; then
            echo "keepgoing=true" >> $GITHUB_ENV
          fi        
      - name: Build Container
        if: ${{ env.keepgoing == 'true' }}
        env:
          recipe: ${{ matrix.recipe }}
        run: |
         ls 
         if [ -f "${{ matrix.recipe }}" ]; then
            sudo -E singularity build container.sif ${{ matrix.recipe }}
            tag=$(echo "${recipe/Singularity\./}")
            if [ "$tag" == "Singularity" ]; then
                tag=latest
            fi
            # Build the container and name by tag
            echo "Tag is $tag."
            echo "tag=$tag" >> $GITHUB_ENV
         else
           echo "${{ matrix.recipe }} is not found."
           echo "Present working directory: $PWD"
           ls
         fi
      - name: Login and Deploy Container
        if: (github.event_name != 'pull_request')
        env:
          keepgoing: ${{ env.keepgoing }}
        run: |         
            if [[ "${keepgoing}" == "true" ]]; then
                echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ secrets.GHCR_USERNAME }} --password-stdin oras://ghcr.io
                singularity push container.sif oras://ghcr.io/${GITHUB_REPOSITORY}:${tag}
            fi

The container is built without error but it fails on the Login and Deploy Container step with a 404 error:

Password (or token when username is empty): 
INFO:    Token stored in /root/.singularity/remote.yaml
FATAL:   Unable to push image to oci registry: unable to push: unexpected status: 404 Not Found
Error: Process completed with exit code 255.

One of the failed runs

Am I doing something wrong?
Thanks,
Gianluca

@vsoch
Copy link
Member

vsoch commented Mar 28, 2022

It says the username is empty - Is GHCR_USERNAME set in your secrets? You could probably just use github.actor instead.

@vsoch
Copy link
Member

vsoch commented Mar 28, 2022

Note that full instructions (including setting this) are in the README https://github.com/singularityhub/github-ci#1-enable-packages

@geeanlooca
Copy link
Author

Thanks for the quick reply.

I indeed forgot to set the username secret, but I tried again using either secrets.GHCR_USERNAME or github.actor and got the same result. Got the same error trying to push a local image on my pc and explicitly writing the username in the command 🤦‍♂️

@geeanlooca
Copy link
Author

Note that I can correctly push a Docker image using a different workflow.

@vsoch
Copy link
Member

vsoch commented Mar 28, 2022

I think if you are getting this error trying to push a local image, you might want to debug that first. E.g., there are many settings for packages and typically you need to make sure they are enabled and your user account has permission to push to a specific repository where they are enabled.

@geeanlooca
Copy link
Author

Thanks again for the assistance! Do you mind if I leave this issue open so I can come back and write a solution in case I am able to solve the problem?

@vsoch
Copy link
Member

vsoch commented Mar 29, 2022

Yes please do! I hope you figure it out and can add some notes here - I definitely faced similar issues when I was first using packages and it's been too long for me to remember the details beyond needing to set up permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants