Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authenticate to multiple gcloud accounts with GitHub Actions

Currently I am connecting to 1 account with the following using GitHub Actions secrets ${{ secrets.GOOGLE_CREDENTIALS }}:

jobs:
  job_id:
    # ...

    steps:
    - uses: 'actions/checkout@v3'

    - id: 'auth'
      name: 'Authenticate to Google Cloud'
      uses: 'google-github-actions/auth@v0'
      with:
        credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'

I would like to connect with multiple accounts, for example, $ {{ secrets.GOOGLE_CREDENTIALS }} and ${{ secrets.beta_GOOGLE_CREDENTIALS }}, is there a way to do that?

like image 494
jipot Avatar asked Oct 27 '25 05:10

jipot


1 Answers

I suspect (I've not tried it!?) you can simply repeat the google-github-actions/auth step for each unique Service Account key that you want to use.

If you need to repeat the same steps for various credentials, you can likely use GitHub matrix.

You should try this to prove it to yourself.

The documentation doesn't appear to cover this use-case but, I suspect, the step is equivalent to gcloud auth activate-service-account.

If so, then subsequent steps will leverage those credentials (presumably either through gcloud or APPLICATION_DEFAULT_CREDENTIALS) until changed by e.g gcloud auth set account ${EMAIL}

like image 72
DazWilkin Avatar answered Oct 29 '25 07:10

DazWilkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!