Strange docker login errors with absent access_token

This issue has been tracked since 2022-04-27.

TL;DR

I'm trying to authenticate with gcr using the docker login command and I get no access_token output. But the auth works fine.

Expected behavior

echo '${{ steps.auth.outputs.access_token }}'

should show output

Observed behavior

echo ''

Action YAML

...
build-and-publish-new-image:
    runs-on: ubuntu-latest
    environment: development
    steps:
    - name: Install Go
      uses: actions/[email protected]
      with:
        go-version: ${{ env.GO_VERSION }}
    
    - name: Checkout
      uses: actions/[email protected]
    
    # GCP Setup
    - name: "Authenticate to Google Cloud"
      uses: "google-github-actions/[email protected]"
      with:
        create_credentials_file: true
        token_format: 'access_token'
        workload_identity_provider: ${{ secrets.PROVIDER_NAME }}
        service_account: ${{ secrets.SERVICE_ACCOUNT }}
    
    - name: View Access token
      run: |-
        echo '${{ steps.auth.outputs.access_token }}'
    
    - name: Docker Artifacts Registry configuration
      uses: 'docker/[email protected]'
      with:
        registry: 'gcr.io' # or REGION-docker.pkg.dev
        username: 'oauth2accesstoken'
        password: '${{ steps.auth.outputs.access_token }}'

Log output

Error: Username and password required


and 

```bash
echo ''


### Additional information

Is there something I'm missing with my yaml configs?
sethvargo wrote this answer on 2022-04-27

Hi @nyanchor

Thank you for opening an issue. A few things:

  • create_credentials_file: true is the default, so you don't technically need that option.

  • You need to give the auth step an "id" property. Right now, you're referencing a step with the id "auth", but no such step exists. This should really be an error on GitHub Actions, but it silently returns the empty string instead. You need to add an "id" property to the step:

    - name: "Authenticate to Google Cloud"
      id: "auth" # <--
      # ... existing values

    Then you can access the outputs. There's a more detailed example in the Usage section of the README.

  • Even if you fix the output naming, it will print as ***, because it's marked as a "secret" in GitHub Actions.

Let me know if you have any questions!

More Details About Repo
Owner Name google-github-actions
Repo Name auth
Full Name google-github-actions/auth
Language TypeScript
Created Date 2021-09-16
Updated Date 2023-03-24
Star Count 573
Watcher Count 16
Fork Count 116
Issue Count 3

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date