Skip to content

Fix GitHub Actions auth step to skip when running from forks#97

Closed
sagarswamirao wants to merge 1 commit into
malloydata:mainfrom
sagarswamirao:fix/github-actions-auth-fork
Closed

Fix GitHub Actions auth step to skip when running from forks#97
sagarswamirao wants to merge 1 commit into
malloydata:mainfrom
sagarswamirao:fix/github-actions-auth-fork

Conversation

@sagarswamirao
Copy link
Copy Markdown
Contributor

Problem

The google-github-actions/auth@v2 action fails when secrets aren't available, which happens for workflows triggered from forks (including Dependabot). The error message is:

Error: google-github-actions/auth failed with: the GitHub Action workflow must specify exactly one of "workload_identity_provider" or "credentials_json"! If you are specifying input values via GitHub secrets, ensure the secret is being injected into the environment. By default, secrets are not passed to workflows triggered from forks, including Dependabot.

Solution

Add a condition to skip the auth step when running from a fork. The condition checks if:

  • It's not a pull request (i.e., it's a push), OR
  • It's a pull request from the same repository (not a fork)

This prevents the workflow from failing when secrets aren't available, while still running authentication for legitimate runs from the main repository.

Changes

  • Added if condition to GCloud auth step to skip when running from forks

The google-github-actions/auth action fails when secrets aren't available,
which happens for workflows triggered from forks (including Dependabot).
This change adds a condition to skip the auth step when running from a fork,
preventing the workflow from failing with 'must specify exactly one of
workload_identity_provider or credentials_json' error.

Signed-off-by: Sagar Swami Rao Kulkarni <sagarswamirao@gmail.com>
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

Successfully merging this pull request may close these issues.

1 participant