This commit refactors a bit of the variable testscripts given the changes in the secret testscripts efforts, removing potentially unnecessary assertions and making these look more similar to other testscripts.
32 lines
1 KiB
Text
32 lines
1 KiB
Text
# Setup environment variables used for testscript
|
|
env REPO=${SCRIPT_NAME}-${RANDOM_STRING}
|
|
env ENV_NAME=testscripts
|
|
env VAR_NAME=TESTSCRIPTS_ENV
|
|
|
|
# Create a repository where the variable will be registered
|
|
exec gh repo create $ORG/$REPO --add-readme --private
|
|
|
|
# Defer repo cleanup
|
|
defer gh repo delete --yes $ORG/$REPO
|
|
|
|
# Clone the repo
|
|
exec gh repo clone $ORG/$REPO
|
|
cd $REPO
|
|
|
|
# Create a repository environment, will fail if organization does not have environment support
|
|
exec gh api /repos/$ORG/$REPO/environments/$ENV_NAME -X PUT --jq '.name'
|
|
|
|
# Verify repository environment variable does not exist
|
|
exec gh variable list --env $ENV_NAME
|
|
! stdout $VAR_NAME
|
|
|
|
# Create a repository environment variable
|
|
exec gh variable set $VAR_NAME --env $ENV_NAME --body 'just a repo env variable'
|
|
|
|
# Verify new repository environment variable exists
|
|
exec gh variable list --env $ENV_NAME
|
|
stdout $VAR_NAME
|
|
|
|
# Verify repository environment variable can be retrieved
|
|
exec gh variable get $VAR_NAME --env $ENV_NAME
|
|
stdout 'just a repo env variable'
|