Repository navigation
ci: skip AWS credential steps for pull requests from forks - #99
Merged
Merged
Conversation
Fork PRs don't receive repo secrets or an OIDC token, so aws-actions/configure-aws-credentials fails with 'Could not load credentials from any providers'. Skip the AWS steps on fork runs (like we already do for dependabot) so the TEST_* env vars stay unset and the AWS-dependent tests skip themselves cleanly. Co-authored-by: Mike Heffner <mikeh@fesnel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CI fails for pull requests opened from forks (e.g. PR #97 — see the failed run). The
Configure AWS credentialsstep errors with:GitHub does not expose repo secrets or an OIDC token to
pull_requestruns from forks, sosecrets.AWS_LAMBDA_CI_ROLE_ARNis empty and the role assumption fails before tests ever run. The workflow already skipped these steps for dependabot (which has the same limitation), but not for fork PRs.Fix
Extend the existing
if:condition on theConfigure AWS credentialsandSet secret test ARNSsteps to also skip when the PR's head repo is a fork:pusheventsgithub.event.pull_requestis null, so the expression evaluates tonull != true→ true, and the steps run as before.fork == false, so the steps also run as before.Set secret test ARNSstep (rather than writing empty values) matters because the test gate isstd::env::var(...).is_ok()— an empty-but-setTEST_*variable would pass the gate and the tests would then fail.No
pull_request_targetis used; fork PRs simply run without any AWS credentials or AWS-related env vars.Why the tests tolerate this
All AWS-dependent tests already gate on their env var being set and return early otherwise:
secrets::secretsmanager::tests::test_basic_secret_retrieval→TEST_SECRETSMANAGER_ARNSsecrets::paramstore::tests::test_basic_paramstore_retrieval→TEST_PARAMSTORE_ARNSenv::tests::test_resolve_multiple_secrets→TEST_ENVSECRET_ARNSenv::tests::test_resolve_secrets_with_failures→TEST_ENVSECRET_FAIL_ARNS(never set in CI)These are the only tests that touch AWS clients (
AwsClient::new/AwsCreds::from_env), so no code changes were needed.Verification
Ran
cargo nextest runlocally with no AWS credentials and allTEST_*vars unset:Re-running the four AWS-dependent tests with
--no-captureconfirms each takes the skip path: