Skip to content

Commit cd14f54

Browse files
sync-test: skip when required connector secret is empty
Add an optional 'required-secrets' input listing env var names that must be non-empty for the test to run. If any are empty the action logs a skip notice and exits 0 instead of failing on a missing-credential side effect (empty grants, jq exit-status failure, etc.). Connectors opt in by setting the input in their workflow: - uses: ConductorOne/github-workflows/actions/sync-test@v3 with: connector: ./baton-foo baton-entitlement: 'role:owner:assigned' baton-principal: 'user@example.com' required-secrets: BATON_FOO_TOKEN Existing callers (no new input) behave exactly as before.
1 parent d2a4189 commit cd14f54

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

actions/sync-test/action.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ inputs:
1818
sleep:
1919
description: 'Sleep time in seconds to wait after each write operation. If not provided, no sleep will be performed.'
2020
required: false
21+
required-secrets:
22+
description: |
23+
Comma- or newline-separated list of env var names that must be non-empty for
24+
this test to run. If any are empty (e.g. the workflow could not pull a fork
25+
secret, or the org secret has not been provisioned yet), the action logs a
26+
skip notice and exits 0 instead of failing on a missing-credential side
27+
effect (no grants returned, empty token, etc.).
28+
29+
Example:
30+
required-secrets: BATON_NETLIFY_ACCESS_TOKEN
31+
required: false
2132

2233
runs:
2334
using: "composite"
@@ -33,5 +44,6 @@ runs:
3344
BATON_PRINCIPAL_TYPE: ${{ inputs.baton-principal-type }}
3445
BATON: baton
3546
SLEEP: ${{ inputs.sleep }}
47+
REQUIRED_SECRETS: ${{ inputs.required-secrets }}
3648
run: ${{ github.action_path }}/grant-revoke.sh
3749
shell: bash

actions/sync-test/grant-revoke.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ if ! command -v $BATON &> /dev/null; then
1616
exit 1
1717
fi
1818

19+
# If required-secrets input was provided, skip the test when any listed env
20+
# var is empty. This unblocks PRs from forks or repos whose org secret has
21+
# not been provisioned yet — running the binary without credentials yields
22+
# empty grants, which then fails the jq exit-status assertion below.
23+
if [ -n "${REQUIRED_SECRETS:-}" ]; then
24+
# Normalize: split on comma or whitespace; iterate non-empty tokens.
25+
for name in ${REQUIRED_SECRETS//,/ }; do
26+
if [ -z "${!name:-}" ]; then
27+
echo "::notice title=sync-test skipped::required secret $name is empty; skipping connector sync test"
28+
exit 0
29+
fi
30+
done
31+
fi
32+
1933
# Error on unbound variables now that we've set BATON
2034
set -u
2135

0 commit comments

Comments
 (0)