-
Notifications
You must be signed in to change notification settings - Fork 203
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
Authenticate with workload federation credential file instead of service account key #174
Comments
Here's more info on keyless auth in Github Actions FYI this is blocked on upgrading the google-auth-client library in the Firebase CLI, it's using 6.x.x which doesn't support authenticating this way. See this release: https://github.com/googleapis/google-auth-library-nodejs/releases/tag/v7.0.0 |
Looking forward to having this merged, currently the only part of our CI/CD pipeline that doesn't work with WLIF |
* Upgrade google-auth-library for FirebaseExtended/action-hosting-deploy#174 * Add changelog entry * Format CHANGELOG.md Co-authored-by: Bryan Kendall <bkend@google.com>
FWIW I have confirmed version 10.1.0 of the cli works with this auth method |
This may end up being relevant |
Based on the usage of npx, this should already use the new CLI. action-hosting-deploy/src/deploy.ts Line 79 in ff6e7dd
I think @steveoh you just need to add the right scopes and your snippet in the issue should work. |
To be fair, that is your code snippet that I cross posted :) I hope to try it this week. |
@rockwotj would using - id: auth
name: 🗝️ Authenticate to Google Cloud
uses: google-github-actions/auth@v0.4.4
with:
token_format: access_token
access_token_scopes: 'email, openid, https://www.googleapis.com/auth/cloud-platform, https://www.googleapis.com/auth/firebase'
workload_identity_provider: ${{ secrets.IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
create_credentials_file: true
- name: 🚀 Firebase Deploy
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.SERVICE_ACCOUNT_EMAIL }}'
channelId: live
projectId: '${{ secrets.PROJECT_ID }}'
target: '${{ secrets.PROJECT_ID }}'
env:
FIREBASE_CLI_PREVIEWS: hostingchannels shows a CI error of need to call |
It seems this action requires the service account is a JSON blob that it writes to disk and then overrides the environment variable that the CLI uses for auth. If you really want to use this action you'll have to hack around by reading the file output in the auth command into that input. To be perfectly honest, it's probably simpler to just run name: "Frontend Preview"
on: ["pull_request"]
jobs:
preview_frontend:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'preview')
environment:
name: preview
url: ${{ steps.deployment_url.outputs.url }}
permissions:
contents: 'read'
id-token: 'write'
deployments: 'write'
steps:
- uses: actions/checkout@v2
- id: 'auth'
name: 'Authenticate to GCP'
uses: 'google-github-actions/auth@v0.4.4'
with:
token_format: 'access_token'
access_token_scopes: 'email, openid, https://www.googleapis.com/auth/cloud-platform, https://www.googleapis.com/auth/firebase'
workload_identity_provider: 'projects/redacted/locations/global/workloadIdentityPools/redacted/providers/redacted'
service_account: 'redacted@redacted.iam.gserviceaccount.com'
create_credentials_file: true
- uses: actions/setup-node@v1
with:
node-version: '16.x'
- name: Deploy
run: npm ci && npx firebase-tools --project redacted hosting:channel:deploy ${{github.event.number}}
- id: deployment_url
name: Set Environment
run: |
URL="$(npx firebase-tools --json --project redacted --non-interactive hosting:channel:open ${{github.event.number}} | jq -r '.result.url')"
echo "::set-output name=url::$URL" |
Ok, but this issue is for making this action work with identity federation, not dropping into the cli and doing it manually. I do appreciate knowing how it could work that way. Thanks! |
Sure - if you want to this action it will need to be modified to make the |
Do we have the attention of any project maintainers? |
|
@Hallerf that works? I can confirm it does not with the following error {
"status": "error",
"error": "Failed to authenticate, have you run firebase login"
} |
Hi! I was stuck in this problem. Cheers |
You can use the following snippet to use - id: auth
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: ...
service_account: ...
create_credentials_file: true
- run: |
echo "SERVICE_ACCOUNT_KEY=$(cat "${{ steps.auth.outputs.credentials_file_path }}" | tr -d '\n')" >> $GITHUB_ENV
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
firebaseServiceAccount: "${{ env.SERVICE_ACCOUNT_KEY }}"
|
The use case you're trying to solve
I would like to use a federated credential file from the auth action to configure the firebase deploy
Change to the action that would solve that use case
The text was updated successfully, but these errors were encountered: