# Setup environment variables
env REPO=$SCRIPT_NAME-$RANDOM_STRING

# Create a repository with a file so it has a default branch
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 secret
exec gh secret set TEST_SECRET_DELETE --body 'secret to delete'

# Verify the secret exists
exec gh secret list
stdout 'TEST_SECRET_DELETE'

# Delete the secret
exec gh secret delete TEST_SECRET_DELETE

# Verify the secret is gone
exec gh secret list
! stdout 'TEST_SECRET_DELETE'
