google-github-actions / auth

A GitHub Action for authenticating to Google Cloud.
https://cloud.google.com/iam
Apache License 2.0
953 stars 195 forks source link

Authentication issue with google artifact registry npm credential helper #259

Closed ludusrusso closed 1 year ago

ludusrusso commented 1 year ago

TL;DR

Not sure what I'm missing but I've a similar issue of #122, setup authentication with workload identity federation but getting the following error with google-artifactregistry-auth

Retrieving application default credentials...
Retrieving credentials from gcloud...
Error: Fail to get credentials. Please run: 
`gcloud auth application-default login`, `gcloud auth login`, or 
`export GOOGLE_APPLICATION_CREDENTIALS=<path/to/service/account/key>`
    at Object.getCreds (/home/runner/work/rc-flow/rc-flow/node_modules/google-artifactregistry-auth/src/auth.js:40:9)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async main (/home/runner/work/rc-flow/rc-flow/node_modules/google-artifactregistry-auth/src/main.js:66:[19](https://github.com/redcarbon-dev/rc-flow/actions/runs/3994786579/jobs/6852896034#step:8:20))
Error: Process completed with exit code 1.

Anyone can help?

Expected behavior

No response

Observed behavior

No response

Action YAML

name: Node.js Package

on:
  push:
    branches: [ main ]

jobs:
  publish-npm:
    runs-on: ubuntu-latest
    permissions:
      contents: 'read'
      id-token: 'write'
    steps:
      - uses: actions/checkout@v3
      - name: Authenticate to Google Cloud
        id: auth
        uses: google-github-actions/auth@v1
        with:
          workload_identity_provider:  ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
          service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
          # export_environment_variables: true
          # create_credentials_file: true
      - name: 'Set up Cloud SDK'
        uses: 'google-github-actions/setup-gcloud@v1'
      - run: gcloud auth login --cred-file=${{ steps.auth.outputs.credentials_file_path }}

      - uses: actions/setup-node@v2
        with:
          node-version: "16"
      - run: npm install
      #  - run: gcloud auth login --cred-file=${{ steps.auth.outputs.credentials_file_path }}

      - run: npx google-artifactregistry-auth --repo-config=.npmrc --credential-config=.npmrc
      - run: npm run build

      - run: sed -i "s/1.0.0-SNAPSHOT/1.0.${GITHUB_RUN_NUMBER}/g" package.json
      - run: npm run artifactregistry-login
      - run: npm publish

Log output

2023-01-24T09:45:10.9700041Z Requested labels: ubuntu-latest
2023-01-24T09:45:10.9700084Z Job defined at: redcarbon-dev/rc-flow/.github/workflows/ci.yaml@refs/heads/main
2023-01-24T09:45:10.9700113Z Waiting for a runner to pick up this job...
2023-01-24T09:45:11.8520087Z Job is waiting for a hosted runner to come online.
2023-01-24T09:45:13.0951925Z Job is about to start running on the hosted runner: GitHub Actions 3 (hosted)
2023-01-24T09:45:16.7572483Z Current runner version: '2.300.2'
2023-01-24T09:45:16.7603917Z ##[group]Operating System
2023-01-24T09:45:16.7604458Z Ubuntu
2023-01-24T09:45:16.7604764Z 22.04.1
2023-01-24T09:45:16.7605148Z LTS
2023-01-24T09:45:16.7605416Z ##[endgroup]
2023-01-24T09:45:16.7605766Z ##[group]Runner Image
2023-01-24T09:45:16.7606135Z Image: ubuntu-22.04
2023-01-24T09:45:16.7606472Z Version: 20230118.2
2023-01-24T09:45:16.7607055Z Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20230118.2/images/linux/Ubuntu2204-Readme.md
2023-01-24T09:45:16.7607723Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20230118.2
2023-01-24T09:45:16.7608141Z ##[endgroup]
2023-01-24T09:45:16.7608502Z ##[group]Runner Image Provisioner
2023-01-24T09:45:16.7608891Z 2.0.98.1
2023-01-24T09:45:16.7609211Z ##[endgroup]
2023-01-24T09:45:16.7609881Z ##[group]GITHUB_TOKEN Permissions
2023-01-24T09:45:16.7610412Z Contents: read
2023-01-24T09:45:16.7610824Z Metadata: read
2023-01-24T09:45:16.7611253Z ##[endgroup]
2023-01-24T09:45:16.7614808Z Secret source: Actions
2023-01-24T09:45:16.7615435Z Prepare workflow directory
2023-01-24T09:45:16.8406212Z Prepare all required actions
2023-01-24T09:45:16.8585381Z Getting action download info
2023-01-24T09:45:17.1094980Z Download action repository 'actions/checkout@v3' (SHA:ac593985615ec2ede58e132d2e21d2b1cbd6127c)
2023-01-24T09:45:17.3922402Z Download action repository 'google-github-actions/auth@v1' (SHA:ef5d53e30bbcd8d0836f4288f5e50ff3e086997d)
2023-01-24T09:45:17.5523471Z Download action repository 'google-github-actions/setup-gcloud@v1' (SHA:d51b5346f85640ec2aa2fa057354d2b82c2fcbce)
2023-01-24T09:45:17.8155068Z Download action repository 'actions/setup-node@v2' (SHA:1f8c6b94b26d0feae1e387ca63ccbdc44d27b561)
2023-01-24T09:45:18.2475771Z ##[group]Run actions/checkout@v3
2023-01-24T09:45:18.2476104Z with:
2023-01-24T09:45:18.2476381Z   repository: redcarbon-dev/rc-flow
2023-01-24T09:45:18.2476918Z   token: ***
2023-01-24T09:45:18.2477159Z   ssh-strict: true
2023-01-24T09:45:18.2477446Z   persist-credentials: true
2023-01-24T09:45:18.2477697Z   clean: true
2023-01-24T09:45:18.2477950Z   fetch-depth: 1
2023-01-24T09:45:18.2478179Z   lfs: false
2023-01-24T09:45:18.2478408Z   submodules: false
2023-01-24T09:45:18.2478678Z   set-safe-directory: true
2023-01-24T09:45:18.2478951Z ##[endgroup]
2023-01-24T09:45:18.5131142Z Syncing repository: redcarbon-dev/rc-flow
2023-01-24T09:45:18.5133424Z ##[group]Getting Git version info
2023-01-24T09:45:18.5134200Z Working directory is '/home/runner/work/rc-flow/rc-flow'
2023-01-24T09:45:18.5135369Z [command]/usr/bin/git version
2023-01-24T09:45:18.5252104Z git version 2.39.1
2023-01-24T09:45:18.5282438Z ##[endgroup]
2023-01-24T09:45:18.5301026Z Temporarily overriding HOME='/home/runner/work/_temp/2b9e2929-8a70-49fb-9907-823520183cb4' before making global git config changes
2023-01-24T09:45:18.5302016Z Adding repository directory to the temporary git global config as a safe directory
2023-01-24T09:45:18.5308551Z [command]/usr/bin/git config --global --add safe.directory /home/runner/work/rc-flow/rc-flow
2023-01-24T09:45:18.5396006Z Deleting the contents of '/home/runner/work/rc-flow/rc-flow'
2023-01-24T09:45:18.5396725Z ##[group]Initializing the repository
2023-01-24T09:45:18.5397178Z [command]/usr/bin/git init /home/runner/work/rc-flow/rc-flow
2023-01-24T09:45:18.5469875Z hint: Using 'master' as the name for the initial branch. This default branch name
2023-01-24T09:45:18.5471759Z hint: is subject to change. To configure the initial branch name to use in all
2023-01-24T09:45:18.5472870Z hint: of your new repositories, which will suppress this warning, call:
2023-01-24T09:45:18.5473862Z hint: 
2023-01-24T09:45:18.5474957Z hint:  git config --global init.defaultBranch <name>
2023-01-24T09:45:18.5475627Z hint: 
2023-01-24T09:45:18.5477289Z hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
2023-01-24T09:45:18.5478311Z hint: 'development'. The just-created branch can be renamed via this command:
2023-01-24T09:45:18.5478895Z hint: 
2023-01-24T09:45:18.5480097Z hint:  git branch -m <name>
2023-01-24T09:45:18.5494659Z Initialized empty Git repository in /home/runner/work/rc-flow/rc-flow/.git/
2023-01-24T09:45:18.5514251Z [command]/usr/bin/git remote add origin https://github.com/redcarbon-dev/rc-flow
2023-01-24T09:45:18.5550938Z ##[endgroup]
2023-01-24T09:45:18.5551590Z ##[group]Disabling automatic garbage collection
2023-01-24T09:45:18.5557342Z [command]/usr/bin/git config --local gc.auto 0
2023-01-24T09:45:18.5589370Z ##[endgroup]
2023-01-24T09:45:18.5589939Z ##[group]Setting up auth
2023-01-24T09:45:18.5598172Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2023-01-24T09:45:18.5634501Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2023-01-24T09:45:18.5961589Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2023-01-24T09:45:18.5995685Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
2023-01-24T09:45:18.6219873Z [command]/usr/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
2023-01-24T09:45:18.6261491Z ##[endgroup]
2023-01-24T09:45:18.6308600Z ##[group]Fetching the repository
2023-01-24T09:45:18.6309594Z [command]/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +821bc7a84092570c1906f10990d4e81ba4bb33aa:refs/remotes/origin/main
2023-01-24T09:45:18.8700779Z remote: Enumerating objects: 47, done.        
2023-01-24T09:45:18.8701314Z remote: Counting objects:   2% (1/47)        
2023-01-24T09:45:18.8701681Z remote: Counting objects:   4% (2/47)        
2023-01-24T09:45:18.8702045Z remote: Counting objects:   6% (3/47)        
2023-01-24T09:45:18.8702401Z remote: Counting objects:   8% (4/47)        
2023-01-24T09:45:18.8702756Z remote: Counting objects:  10% (5/47)        
2023-01-24T09:45:18.8703109Z remote: Counting objects:  12% (6/47)        
2023-01-24T09:45:18.8703460Z remote: Counting objects:  14% (7/47)        
2023-01-24T09:45:18.8703809Z remote: Counting objects:  17% (8/47)        
2023-01-24T09:45:18.8704156Z remote: Counting objects:  19% (9/47)        
2023-01-24T09:45:18.8704493Z remote: Counting objects:  21% (10/47)        
2023-01-24T09:45:18.8704849Z remote: Counting objects:  23% (11/47)        
2023-01-24T09:45:18.8705264Z remote: Counting objects:  25% (12/47)        
2023-01-24T09:45:18.8705572Z remote: Counting objects:  27% (13/47)        
2023-01-24T09:45:18.8705882Z remote: Counting objects:  29% (14/47)        
2023-01-24T09:45:18.8706190Z remote: Counting objects:  31% (15/47)        
2023-01-24T09:45:18.8706491Z remote: Counting objects:  34% (16/47)        
2023-01-24T09:45:18.8706784Z remote: Counting objects:  36% (17/47)        
2023-01-24T09:45:18.8707089Z remote: Counting objects:  38% (18/47)        
2023-01-24T09:45:18.8707392Z remote: Counting objects:  40% (19/47)        
2023-01-24T09:45:18.8715873Z remote: Counting objects:  42% (20/47)        
2023-01-24T09:45:18.8716371Z remote: Counting objects:  44% (21/47)        
2023-01-24T09:45:18.8716716Z remote: Counting objects:  46% (22/47)        
2023-01-24T09:45:18.8717050Z remote: Counting objects:  48% (23/47)        
2023-01-24T09:45:18.8717371Z remote: Counting objects:  51% (24/47)        
2023-01-24T09:45:18.8717697Z remote: Counting objects:  53% (25/47)        
2023-01-24T09:45:18.8718023Z remote: Counting objects:  55% (26/47)        
2023-01-24T09:45:18.8718369Z remote: Counting objects:  57% (27/47)        
2023-01-24T09:45:18.8718693Z remote: Counting objects:  59% (28/47)        
2023-01-24T09:45:18.8719018Z remote: Counting objects:  61% (29/47)        
2023-01-24T09:45:18.8719332Z remote: Counting objects:  63% (30/47)        
2023-01-24T09:45:18.8719899Z remote: Counting objects:  65% (31/47)        
2023-01-24T09:45:18.8720225Z remote: Counting objects:  68% (32/47)        
2023-01-24T09:45:18.8720553Z remote: Counting objects:  70% (33/47)        
2023-01-24T09:45:18.8720881Z remote: Counting objects:  72% (34/47)        
2023-01-24T09:45:18.8721207Z remote: Counting objects:  74% (35/47)        
2023-01-24T09:45:18.8721533Z remote: Counting objects:  76% (36/47)        
2023-01-24T09:45:18.8721843Z remote: Counting objects:  78% (37/47)        
2023-01-24T09:45:18.8722166Z remote: Counting objects:  80% (38/47)        
2023-01-24T09:45:18.8722493Z remote: Counting objects:  82% (39/47)        
2023-01-24T09:45:18.8722816Z remote: Counting objects:  85% (40/47)        
2023-01-24T09:45:18.8723143Z remote: Counting objects:  87% (41/47)        
2023-01-24T09:45:18.8723470Z remote: Counting objects:  89% (42/47)        
2023-01-24T09:45:18.8723792Z remote: Counting objects:  91% (43/47)        
2023-01-24T09:45:18.8724101Z remote: Counting objects:  93% (44/47)        
2023-01-24T09:45:18.8724425Z remote: Counting objects:  95% (45/47)        
2023-01-24T09:45:18.8724750Z remote: Counting objects:  97% (46/47)        
2023-01-24T09:45:18.8725071Z remote: Counting objects: 100% (47/47)        
2023-01-24T09:45:18.8725415Z remote: Counting objects: 100% (47/47), done.        
2023-01-24T09:45:18.8725789Z remote: Compressing objects:   2% (1/41)        
2023-01-24T09:45:18.8726130Z remote: Compressing objects:   4% (2/41)        
2023-01-24T09:45:18.8726479Z remote: Compressing objects:   7% (3/41)        
2023-01-24T09:45:18.8726823Z remote: Compressing objects:   9% (4/41)        
2023-01-24T09:45:18.8727174Z remote: Compressing objects:  12% (5/41)        
2023-01-24T09:45:18.8727605Z remote: Compressing objects:  14% (6/41)        
2023-01-24T09:45:18.8727956Z remote: Compressing objects:  17% (7/41)        
2023-01-24T09:45:18.8728303Z remote: Compressing objects:  19% (8/41)        
2023-01-24T09:45:18.8728633Z remote: Compressing objects:  21% (9/41)        
2023-01-24T09:45:18.8728992Z remote: Compressing objects:  24% (10/41)        
2023-01-24T09:45:18.8729348Z remote: Compressing objects:  26% (11/41)        
2023-01-24T09:45:18.8729700Z remote: Compressing objects:  29% (12/41)        
2023-01-24T09:45:18.8730047Z remote: Compressing objects:  31% (13/41)        
2023-01-24T09:45:18.8730391Z remote: Compressing objects:  34% (14/41)        
2023-01-24T09:45:18.8730734Z remote: Compressing objects:  36% (15/41)        
2023-01-24T09:45:18.8731061Z remote: Compressing objects:  39% (16/41)        
2023-01-24T09:45:18.8731433Z remote: Compressing objects:  41% (17/41)        
2023-01-24T09:45:18.8731762Z remote: Compressing objects:  43% (18/41)        
2023-01-24T09:45:18.8732106Z remote: Compressing objects:  46% (19/41)        
2023-01-24T09:45:18.8732449Z remote: Compressing objects:  48% (20/41)        
2023-01-24T09:45:18.8732785Z remote: Compressing objects:  51% (21/41)        
2023-01-24T09:45:18.8733125Z remote: Compressing objects:  53% (22/41)        
2023-01-24T09:45:18.8733469Z remote: Compressing objects:  56% (23/41)        
2023-01-24T09:45:18.8733810Z remote: Compressing objects:  58% (24/41)        
2023-01-24T09:45:18.8734140Z remote: Compressing objects:  60% (25/41)        
2023-01-24T09:45:18.8734478Z remote: Compressing objects:  63% (26/41)        
2023-01-24T09:45:18.8734819Z remote: Compressing objects:  65% (27/41)        
2023-01-24T09:45:18.8735155Z remote: Compressing objects:  68% (28/41)        
2023-01-24T09:45:18.8735495Z remote: Compressing objects:  70% (29/41)        
2023-01-24T09:45:18.8735832Z remote: Compressing objects:  73% (30/41)        
2023-01-24T09:45:18.8736203Z remote: Compressing objects:  75% (31/41)        
2023-01-24T09:45:18.8736533Z remote: Compressing objects:  78% (32/41)        
2023-01-24T09:45:18.8736873Z remote: Compressing objects:  80% (33/41)        
2023-01-24T09:45:18.8737215Z remote: Compressing objects:  82% (34/41)        
2023-01-24T09:45:18.8737552Z remote: Compressing objects:  85% (35/41)        
2023-01-24T09:45:18.8737969Z remote: Compressing objects:  87% (36/41)        
2023-01-24T09:45:18.8738308Z remote: Compressing objects:  90% (37/41)        
2023-01-24T09:45:18.8738649Z remote: Compressing objects:  92% (38/41)        
2023-01-24T09:45:18.8738974Z remote: Compressing objects:  95% (39/41)        
2023-01-24T09:45:18.8739317Z remote: Compressing objects:  97% (40/41)        
2023-01-24T09:45:18.8739659Z remote: Compressing objects: 100% (41/41)        
2023-01-24T09:45:18.8740018Z remote: Compressing objects: 100% (41/41), done.        
2023-01-24T09:45:18.8948262Z remote: Total 47 (delta 4), reused 26 (delta 0), pack-reused 0        
2023-01-24T09:45:18.9128314Z From https://github.com/redcarbon-dev/rc-flow
2023-01-24T09:45:18.9129281Z  * [new ref]         821bc7a84092570c1906f10990d4e81ba4bb33aa -> origin/main
2023-01-24T09:45:18.9175074Z ##[endgroup]
2023-01-24T09:45:18.9271723Z ##[group]Determining the checkout info
2023-01-24T09:45:18.9272236Z ##[endgroup]
2023-01-24T09:45:18.9272713Z ##[group]Checking out the ref
2023-01-24T09:45:18.9273597Z [command]/usr/bin/git checkout --progress --force -B main refs/remotes/origin/main
2023-01-24T09:45:18.9274047Z Switched to a new branch 'main'
2023-01-24T09:45:18.9274417Z branch 'main' set up to track 'origin/main'.
2023-01-24T09:45:18.9275362Z ##[endgroup]
2023-01-24T09:45:18.9360501Z [command]/usr/bin/git log -1 --format='%H'
2023-01-24T09:45:18.9387835Z '821bc7a84092570c1906f10990d4e81ba4bb33aa'
2023-01-24T09:45:18.9741886Z ##[group]Run google-github-actions/auth@v1
2023-01-24T09:45:18.9742209Z with:
2023-01-24T09:45:18.9742882Z   workload_identity_provider: ***
2023-01-24T09:45:18.9743366Z   service_account: ***
2023-01-24T09:45:18.9743644Z   create_credentials_file: true
2023-01-24T09:45:18.9743947Z   export_environment_variables: true
2023-01-24T09:45:18.9744242Z   cleanup_credentials: true
2023-01-24T09:45:18.9744520Z   access_token_lifetime: 3600s
2023-01-24T09:45:18.9744884Z   access_token_scopes: https://www.googleapis.com/auth/cloud-platform
2023-01-24T09:45:18.9745245Z   retries: 0
2023-01-24T09:45:18.9745492Z   id_token_include_email: false
2023-01-24T09:45:18.9745743Z ##[endgroup]
2023-01-24T09:45:19.1207328Z Created credentials file at "/home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json"
2023-01-24T09:45:19.1376010Z ##[group]Run google-github-actions/setup-gcloud@v1
2023-01-24T09:45:19.1376432Z with:
2023-01-24T09:45:19.1376736Z   version: latest
2023-01-24T09:45:19.1377065Z env:
2023-01-24T09:45:19.1377583Z   CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:19.1378223Z   GOOGLE_APPLICATION_CREDENTIALS: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:19.1378832Z   GOOGLE_GHA_CREDS_PATH: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:19.1379324Z   CLOUDSDK_CORE_PROJECT: xxx-xxxx
2023-01-24T09:45:19.1379756Z   CLOUDSDK_PROJECT: xxx-xxxx
2023-01-24T09:45:19.1380149Z   GCLOUD_PROJECT: xxx-xxxx
2023-01-24T09:45:19.1380475Z   GCP_PROJECT: xxx-xxxx
2023-01-24T09:45:19.1380865Z   GOOGLE_CLOUD_PROJECT: xxx-xxxx
2023-01-24T09:45:19.1381245Z ##[endgroup]
2023-01-24T09:45:20.2039770Z [command]/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/ac60908b-e8d0-4685-bbf5-661f9e7cd65d -f /home/runner/work/_temp/b12484ad-5a8d-40cb-8f38-481528fb21e5
2023-01-24T09:45:37.4194639Z Successfully authenticated
2023-01-24T09:45:37.4406650Z ##[group]Run gcloud auth login --cred-file=/home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:37.4407211Z gcloud auth login --cred-file=/home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:37.4466635Z shell: /usr/bin/bash -e {0}
2023-01-24T09:45:37.4466888Z env:
2023-01-24T09:45:37.4467242Z   CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:37.4467717Z   GOOGLE_APPLICATION_CREDENTIALS: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:37.4468328Z   GOOGLE_GHA_CREDS_PATH: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:37.4468682Z   CLOUDSDK_CORE_PROJECT: xxx-xxxx
2023-01-24T09:45:37.4468964Z   CLOUDSDK_PROJECT: xxx-xxxx
2023-01-24T09:45:37.4469223Z   GCLOUD_PROJECT: xxx-xxxx
2023-01-24T09:45:37.4469481Z   GCP_PROJECT: xxx-xxxx
2023-01-24T09:45:37.4469790Z   GOOGLE_CLOUD_PROJECT: xxx-xxxx
2023-01-24T09:45:37.4470118Z   CLOUDSDK_METRICS_ENVIRONMENT: github-actions-setup-gcloud
2023-01-24T09:45:37.4470400Z ##[endgroup]
2023-01-24T09:45:38.0445831Z 
2023-01-24T09:45:38.0446699Z You are already authenticated with 
2023-01-24T09:45:38.0448165Z '***'.
2023-01-24T09:45:38.0448786Z Do you wish to proceed and overwrite existing credentials?
2023-01-24T09:45:38.0449329Z 
2023-01-24T09:45:38.0449780Z Do you want to continue (Y/n)?  
2023-01-24T09:45:38.0521371Z 
2023-01-24T09:45:38.0522799Z Authenticated with external account credentials for: [***].
2023-01-24T09:45:38.0569999Z Your current project is [xxx-xxxx].  You can change this setting by running:
2023-01-24T09:45:38.0570428Z   $ gcloud config set project PROJECT_ID
2023-01-24T09:45:38.1510534Z ##[group]Run actions/setup-node@v2
2023-01-24T09:45:38.1510790Z with:
2023-01-24T09:45:38.1511000Z   node-version: 16
2023-01-24T09:45:38.1511232Z   always-auth: false
2023-01-24T09:45:38.1511460Z   check-latest: false
2023-01-24T09:45:38.1511885Z   token: ***
2023-01-24T09:45:38.1512068Z env:
2023-01-24T09:45:38.1512408Z   CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:38.1512879Z   GOOGLE_APPLICATION_CREDENTIALS: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:38.1513491Z   GOOGLE_GHA_CREDS_PATH: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:38.1513840Z   CLOUDSDK_CORE_PROJECT: xxx-xxxx
2023-01-24T09:45:38.1514126Z   CLOUDSDK_PROJECT: xxx-xxxx
2023-01-24T09:45:38.1514396Z   GCLOUD_PROJECT: xxx-xxxx
2023-01-24T09:45:38.1514651Z   GCP_PROJECT: xxx-xxxx
2023-01-24T09:45:38.1514948Z   GOOGLE_CLOUD_PROJECT: xxx-xxxx
2023-01-24T09:45:38.1515275Z   CLOUDSDK_METRICS_ENVIRONMENT: github-actions-setup-gcloud
2023-01-24T09:45:38.1515563Z ##[endgroup]
2023-01-24T09:45:38.4380457Z Found in cache @ /opt/hostedtoolcache/node/16.19.0/x64
2023-01-24T09:45:38.4508646Z ##[group]Run npm install
2023-01-24T09:45:38.4508906Z npm install
2023-01-24T09:45:38.4560815Z shell: /usr/bin/bash -e {0}
2023-01-24T09:45:38.4561045Z env:
2023-01-24T09:45:38.4561395Z   CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:38.4561868Z   GOOGLE_APPLICATION_CREDENTIALS: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:38.4562303Z   GOOGLE_GHA_CREDS_PATH: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:38.4562661Z   CLOUDSDK_CORE_PROJECT: xxx-xxxx
2023-01-24T09:45:38.4562940Z   CLOUDSDK_PROJECT: xxx-xxxx
2023-01-24T09:45:38.4563206Z   GCLOUD_PROJECT: xxx-xxxx
2023-01-24T09:45:38.4563461Z   GCP_PROJECT: xxx-xxxx
2023-01-24T09:45:38.4563727Z   GOOGLE_CLOUD_PROJECT: xxx-xxxx
2023-01-24T09:45:38.4564039Z   CLOUDSDK_METRICS_ENVIRONMENT: github-actions-setup-gcloud
2023-01-24T09:45:38.4564367Z ##[endgroup]
2023-01-24T09:45:48.0110939Z 
2023-01-24T09:45:48.0119909Z added 651 packages, and audited 652 packages in 9s
2023-01-24T09:45:48.0120460Z 
2023-01-24T09:45:48.0120749Z 50 packages are looking for funding
2023-01-24T09:45:48.0121131Z   run `npm fund` for details
2023-01-24T09:45:48.0127085Z 
2023-01-24T09:45:48.0127356Z found 0 vulnerabilities
2023-01-24T09:45:48.0303478Z ##[group]Run npx google-artifactregistry-auth --repo-config=.npmrc --credential-config=.npmrc
2023-01-24T09:45:48.0304074Z npx google-artifactregistry-auth --repo-config=.npmrc --credential-config=.npmrc
2023-01-24T09:45:48.0362797Z shell: /usr/bin/bash -e {0}
2023-01-24T09:45:48.0363030Z env:
2023-01-24T09:45:48.0363379Z   CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:48.0363845Z   GOOGLE_APPLICATION_CREDENTIALS: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:48.0364277Z   GOOGLE_GHA_CREDS_PATH: /home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json
2023-01-24T09:45:48.0364629Z   CLOUDSDK_CORE_PROJECT: xxx-xxxx
2023-01-24T09:45:48.0364907Z   CLOUDSDK_PROJECT: xxx-xxxx
2023-01-24T09:45:48.0365163Z   GCLOUD_PROJECT: xxx-xxxx
2023-01-24T09:45:48.0365418Z   GCP_PROJECT: xxx-xxxx
2023-01-24T09:45:48.0365723Z   GOOGLE_CLOUD_PROJECT: xxx-xxxx
2023-01-24T09:45:48.0366048Z   CLOUDSDK_METRICS_ENVIRONMENT: github-actions-setup-gcloud
2023-01-24T09:45:48.0366323Z ##[endgroup]
2023-01-24T09:45:48.9348872Z Retrieving application default credentials...
2023-01-24T09:45:49.0310226Z Retrieving credentials from gcloud...
2023-01-24T09:45:49.7881856Z Error: Fail to get credentials. Please run: 
2023-01-24T09:45:49.7885036Z `gcloud auth application-default login`, `gcloud auth login`, or 
2023-01-24T09:45:49.7885900Z `export GOOGLE_APPLICATION_CREDENTIALS=<path/to/service/account/key>`
2023-01-24T09:45:49.7886874Z     at Object.getCreds (/home/runner/work/rc-flow/rc-flow/node_modules/google-artifactregistry-auth/src/auth.js:40:9)
2023-01-24T09:45:49.7887531Z     at processTicksAndRejections (node:internal/process/task_queues:96:5)
2023-01-24T09:45:49.7888479Z     at async main (/home/runner/work/rc-flow/rc-flow/node_modules/google-artifactregistry-auth/src/main.js:66:19)
2023-01-24T09:45:49.8031366Z ##[error]Process completed with exit code 1.
2023-01-24T09:45:49.8102501Z Post job cleanup.
2023-01-24T09:45:49.8812142Z Removed exported credentials at "/home/runner/work/rc-flow/rc-flow/gha-creds-73e89792c9785166.json".
2023-01-24T09:45:49.8927792Z Post job cleanup.
2023-01-24T09:45:50.0207048Z [command]/usr/bin/git version
2023-01-24T09:45:50.0258091Z git version 2.39.1
2023-01-24T09:45:50.0303734Z Temporarily overriding HOME='/home/runner/work/_temp/00c81744-037f-4c42-aaf9-4bf0071095df' before making global git config changes
2023-01-24T09:45:50.0304819Z Adding repository directory to the temporary git global config as a safe directory
2023-01-24T09:45:50.0310641Z [command]/usr/bin/git config --global --add safe.directory /home/runner/work/rc-flow/rc-flow
2023-01-24T09:45:50.0356047Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2023-01-24T09:45:50.0395939Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2023-01-24T09:45:50.0624666Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2023-01-24T09:45:50.0655229Z http.https://github.com/.extraheader
2023-01-24T09:45:50.0668686Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
2023-01-24T09:45:50.0707010Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
2023-01-24T09:45:50.1154873Z Cleaning up orphan processes

Additional information

No response

github-actions[bot] commented 1 year ago

Hi there @ludusrusso :wave:!

Thank you for opening an issue. Our team will triage this as soon as we can. Please take a moment to review the troubleshooting steps which lists common error messages and their resolution steps.

sethvargo commented 1 year ago

Hi @ludusrusso

  1. You should not need this line:

    - run: gcloud auth login --cred-file=${{ steps.auth.outputs.credentials_file_path }}

    The setup-gcloud action consumes the exported credentials from auth automatically.

  2. What does the npm publish target actually do?

ludusrusso commented 1 year ago

Hi @sethvargo, I know that that line s not required, it was an attempt to solve it as suggested here: https://github.com/google-github-actions/auth/issues/122#issuecomment-1027226409

npm publish should deploy on a google cloud artifact npm regsitry I've created, but as you can see the problem is on the line npm run artifactregistry-login.

sethvargo commented 1 year ago

Right, but what commands are those npm running under the hood in the package.json?

ludusrusso commented 1 year ago

here is the package.json file

{
  "name": "@rc-dev/rc-flow",
  "version": "1.0.0-SNAPSHOT",
  "type": "module",
  "files": [
    "lib"
  ],
  "main": "./lib/rc-flow.umd.js",
  "module": "./lib/rc-flow.es.js",
  "types": "./lib/main.d.ts",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build && tailwindcss -o ./lib/styles.css",
    "preview": "vite preview",
    "test": "jest",
    "artifactregistry-login": "npx google-artifactregistry-auth"
  },
  "dependencies": {
    "@emotion/styled": "^11.10.5",
    "@headlessui/react": "^1.7.7",
    "@heroicons/react": "^2.0.13",
    "cuid": "^2.1.8",
    "prettier": "^2.8.3"
  },
  "devDependencies": {
    "@types/jest": "^29.2.5",
    "@types/node": "^18.11.18",
    "@types/react": "^18.0.26",
    "@types/react-dom": "^18.0.9",
    "@vitejs/plugin-react": "^3.0.0",
    "autoprefixer": "^10.4.13",
    "google-artifactregistry-auth": "^3.0.2",
    "jest": "^29.3.1",
    "postcss": "^8.4.21",
    "tailwindcss": "^3.2.4",
    "ts-jest": "^29.0.5",
    "ts-node": "^10.9.1",
    "typescript": "^4.9.4",
    "vite": "^4.0.0",
    "vite-plugin-dts": "^1.7.1"
  },
  "peerDependencies": {
    "react": ">=18.2.0",
    "react-dom": ">=18.2.0",
    "reactflow": ">=11.4.2",
    "zustand": ">=4.3.2"
  }
}
ludusrusso commented 1 year ago

Anyway it works with credential passed as json keys to the action. The problem seems to be in the workload identity.

This is the actions that works

name: Node.js Package

on:
  push:
    branches: [ main ]

jobs:
  publish-npm:
    runs-on: ubuntu-latest
    permissions:
      contents: 'read'
      id-token: 'write'
    steps:
      - uses: actions/checkout@v3
      - name: Authenticate to Google Cloud
        id: auth
        uses: google-github-actions/auth@v1
        with:
          # workload_identity_provider:  ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
          # service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
          project_id: ${{ secrets.GCP_PROJECT_ID }}
          credentials_json: ${{ secrets.GCP_ARTIFACTORY_SERVICE_ACCOUNT}}
      - name: 'Set up Cloud SDK'
        uses: 'google-github-actions/setup-gcloud@v1'
      - uses: actions/setup-node@v2
        with:
          node-version: "16"
      - run: npm install
      - run: npm run build
      - run: sed -i "s/1.0.0-SNAPSHOT/0.0.0-build-${GITHUB_RUN_NUMBER}/g" package.json
      - run: npm run artifactregistry-login
      - run: npm publish 
sethvargo commented 1 year ago

What does npx google-artifactregistry-auth do?

ludusrusso commented 1 year ago

It should perform login with google npm artifact registry in order to do npm publish on a private registry https://cloud.google.com/artifact-registry/docs/nodejs/authentication?hl=it

sethvargo commented 1 year ago

It sounds like https://www.npmjs.com/package/google-artifactregistry-auth does not support Workload Identity Federation. I would suggest opening an issue against that repository to support WIF.