-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Publish to ghcr (cherry picked from commit d132a45)
- Loading branch information
1 parent
5140866
commit ed7baaa
Showing
3 changed files
with
83 additions
and
69 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,40 @@ | ||
#! /bin/bash | ||
|
||
# Fail immedietly if any command fails | ||
# Fail immediately if any command fails | ||
set -e | ||
|
||
# Get command line arguments | ||
ACR_HOST=$1 | ||
GHCR_ORG=$1 | ||
GHCR_PATH=$2 | ||
RECIPE_VERSION=$2 | ||
|
||
# Print usage information | ||
function print_usage() { | ||
echo "Usage: $0 <ACR_HOST> <RECIPE_VERSION>" | ||
echo " Deletes all recipes in the repository from the Azure Container Registry. Requires you to be logged into Azure via az login." | ||
echo " ACR_HOST: Host name of the Azure Container Registry. For example, myregistry.azurecr.io." | ||
echo "Usage: $0 <GHCR_ORG> <RECIPE_VERSION>" | ||
echo " Deletes all recipes in the repository from the GitHub Container Registry. Requires you to be logged into GitHub." | ||
echo " GHCR_ORG: Organization name of the GitHub Container Registry. For example, radius-project" | ||
echo " GHCR_PATH: Path name for Recipe storage. For example, recipes" | ||
echo " RECIPE_VERSION: Version of the recipe to publish. For example, 1.0" | ||
} | ||
|
||
# Verify that the required arguments are present | ||
if [ -z "$ACR_HOST" ] || [ -z "$RECIPE_VERSION" ]; then | ||
if [ -z "$GHCR_ORG" ] || [ -z "$GHCR_PATH" ] || [ -z "$RECIPE_VERSION" ]; then | ||
echo "Missing required arguments" | ||
print_usage | ||
exit 1 | ||
fi | ||
|
||
# Login to Azure Container Registry | ||
az acr login --name $ACR_HOST | ||
|
||
for RECIPE in $(find . -type f -name "*.bicep") | ||
do | ||
# Get the recipe name and directory name | ||
# ./azure/redis-azure.bicep -> redis-azure and azure, respectively | ||
export FILE_NAME=$(basename $RECIPE | cut -d. -f1) | ||
export DIR_NAME=$(dirname $RECIPE | cut -d/ -f2) | ||
|
||
echo "Deleting $ACR_HOST/recipes/$DIR_NAME/$FILE_NAME:1.0" | ||
az acr repository delete --name $ACR_HOST --image "recipes/$DIR_NAME/$FILE_NAME:$RECIPE_VERSION" --yes | ||
echo "Deleting ghcr.io/$GHCR_ORG/$GHCR_PATH/$DIR_NAME/$FILE_NAME:$RECIPE_VERSION" | ||
gh api \ | ||
--method DELETE \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
/orgs/$GHCR_ORG/packages/container/$GHCR_PATH/$DIR_NAME/$FILE_NAME:$RECIPE_VERSION | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,43 @@ | ||
#! /bin/bash | ||
|
||
# Fail immedietly if any command fails | ||
# Fail immediately if any command fails | ||
set -e | ||
|
||
# Get command line arguments | ||
BICEP_PATH=$1 | ||
ACR_HOST=$2 | ||
GHCR_ORG=$1 | ||
GHCR_PATH=$2 | ||
RECIPE_VERSION=$3 | ||
|
||
BICEP_EXECUTABLE="$BICEP_PATH/rad-bicep" | ||
|
||
# Print usage information | ||
function print_usage() { | ||
echo "Usage: $0 <BICEP_PATH> <ACR_HOST> <RECIPE_VERSION>" | ||
echo " Publishes all recipes in the repository to the Azure Container Registry. Requires you to be logged into Azure via az login." | ||
echo " BICEP_PATH: Path to the bicep executable. For example, ~/.rad/bin" | ||
echo " ACR_HOST: Host name of the Azure Container Registry. For example, myregistry.azurecr.io." | ||
echo "Usage: $0 <GHCR_ORG> <RECIPE_VERSION>" | ||
echo " Publishes all recipes in the repository to the GitHub Container Registry. Requires you to be logged into GitHub" | ||
echo " GHCR_ORG: Organization name of the GitHub Container Registry. For example, radius-project" | ||
echo " GHCR_PATH: Path name for Recipe storage. For example, recipes" | ||
echo " RECIPE_VERSION: Version of the recipe to publish. For example, 1.0" | ||
} | ||
|
||
# Verify that the required arguments are present | ||
if [ -z "$BICEP_PATH" ] || [ -z "$ACR_HOST" ] || [ -z "$RECIPE_VERSION" ]; then | ||
if [ -z "$GHCR_ORG" ] || [ -z "$GHCR_PATH" ] || [ -z "$RECIPE_VERSION" ]; then | ||
echo "Missing required arguments" | ||
print_usage | ||
exit 1 | ||
fi | ||
|
||
echo "## Recipes published to $ACR_HOST" >> $GITHUB_STEP_SUMMARY | ||
# We create output that's intended to be consumed by the GitHub Action summary. If we're | ||
# not running in a GitHub Action, we'll just silence the output. | ||
if [[ -z "$GITHUB_STEP_SUMMARY" ]]; then | ||
GITHUB_STEP_SUMMARY=/dev/null | ||
fi | ||
|
||
echo "## Recipes published to ghcr.io/$GHCR_ORG/$GHCR_PATH" >> $GITHUB_STEP_SUMMARY | ||
for RECIPE in $(find . -type f -name "*.bicep") | ||
do | ||
# Get the platform (file) name and resource (directory) name | ||
export FILE_NAME=$(basename $RECIPE | cut -d. -f1) # rediscaches | ||
export DIR_NAME=$(dirname $RECIPE | cut -d/ -f2) # dev | ||
|
||
echo "Publishing $DIR_NAME/$FILE_NAME to $ACR_HOST from $RECIPE" | ||
echo "- $ACR_HOST/recipes/$DIR_NAME/$FILE_NAME:$RECIPE_VERSION" >> $GITHUB_STEP_SUMMARY | ||
$BICEP_EXECUTABLE publish $RECIPE --target "br:$ACR_HOST/recipes/$DIR_NAME/$FILE_NAME:$RECIPE_VERSION" | ||
echo "Publishing $DIR_NAME/$FILE_NAME to ghcr.io/$GHCR_ORG/$GHCR_PATH from $RECIPE" | ||
echo "- ghcr.io/$GHCR_ORG/$GHCR_PATH/$DIR_NAME/$FILE_NAME:$RECIPE_VERSION" >> $GITHUB_STEP_SUMMARY | ||
rad bicep publish --file $RECIPE --target "br:ghcr.io/$GHCR_ORG/$GHCR_PATH/$DIR_NAME/$FILE_NAME:$RECIPE_VERSION" | ||
done |
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