Skip to content

Instantly share code, notes, and snippets.

@lukaszraczylo
Created November 28, 2022 11:58
Show Gist options
  • Save lukaszraczylo/1e39ca3102c63f57fee41e97150b484a to your computer and use it in GitHub Desktop.
Save lukaszraczylo/1e39ca3102c63f57fee41e97150b484a to your computer and use it in GitHub Desktop.
#!/bin/bash
# This script sets the token for all repositories within organisation.
set -e
organisationName=$1
if [ -z "$organisationName" ]; then
echo "Please provide organisation name"
exit 1
fi
__listGitRepositoriesInOrganisation() {
listOfRepositories=$(gh repo list $organisationName | sed -e 's/|/ /' -e "s/$organisationName\///" | awk '{print $1}')
}
__listAndRemoveAllReleases() {
for repository in $listOfRepositories; do
echo "Setting GHCR_TOKEN for $repository"
gh secret set -R $organisationName/$repository GHCR_TOKEN -b"${GHCR_TOKEN_TELEGRAM_APP}"
echo "Setting DRONE_TOKEN for $repository"
gh secret set -R $organisationName/$repository DRONE_TOKEN -b"${DRONE_TOKEN}"
echo "Setting DRONE_SERVER for $repository"
gh secret set -R $organisationName/$repository DRONE_SERVER -b"${DRONE_SERVER}"
done
}
echo "Cleaning releases in GH org $organisationName"
__listGitRepositoriesInOrganisation
__listAndRemoveAllReleases "$listOfRepositories"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment