Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions actions/sync-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ inputs:
sleep:
description: 'Sleep time in seconds to wait after each write operation. If not provided, no sleep will be performed.'
required: false
required-secrets:
description: |
Comma- or newline-separated list of env var names that must be non-empty for
this test to run. If any are empty (e.g. the workflow could not pull a fork
secret, or the org secret has not been provisioned yet), the action logs a
skip notice and exits 0 instead of failing on a missing-credential side
effect (no grants returned, empty token, etc.).

Example:
required-secrets: BATON_NETLIFY_ACCESS_TOKEN
required: false

runs:
using: "composite"
Expand All @@ -33,5 +44,6 @@ runs:
BATON_PRINCIPAL_TYPE: ${{ inputs.baton-principal-type }}
BATON: baton
SLEEP: ${{ inputs.sleep }}
REQUIRED_SECRETS: ${{ inputs.required-secrets }}
run: ${{ github.action_path }}/grant-revoke.sh
shell: bash
14 changes: 14 additions & 0 deletions actions/sync-test/grant-revoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ if ! command -v $BATON &> /dev/null; then
exit 1
fi

# If required-secrets input was provided, skip the test when any listed env
# var is empty. This unblocks PRs from forks or repos whose org secret has
# not been provisioned yet — running the binary without credentials yields
# empty grants, which then fails the jq exit-status assertion below.
if [ -n "${REQUIRED_SECRETS:-}" ]; then
# Normalize: split on comma or whitespace; iterate non-empty tokens.
for name in ${REQUIRED_SECRETS//,/ }; do
if [ -z "${!name:-}" ]; then
echo "::notice title=sync-test skipped::required secret $name is empty; skipping connector sync test"
exit 0
fi
done
fi

# Error on unbound variables now that we've set BATON
set -u

Expand Down