Created
November 28, 2022 11:58
-
-
Save lukaszraczylo/1e39ca3102c63f57fee41e97150b484a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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