[bitnami/containers] Feature: retry CD pipeline manually (#21545)

Signed-off-by: Fran Mulero <fmulero@vmware.com>

Signed-off-by: Fran Mulero <fmulero@vmware.com>
This commit is contained in:
Fran Mulero
2023-01-24 10:45:25 +01:00
committed by GitHub
parent 6c20ddd013
commit e816896740
+16 -9
View File
@@ -1,5 +1,12 @@
name: '[CI/CD] CD Pipeline'
run-name: " ${{ github.event_name == 'workflow_dispatch' && format('[CD] Retrying SHA: {0}', inputs.sha) || '' }}"
on: # rebuild any PRs and main branch changes
workflow_dispatch:
inputs:
sha:
description: 'Commit to retry'
required: true
default: 'HEAD'
push:
branches:
- main
@@ -14,8 +21,8 @@ jobs:
runs-on: ubuntu-latest
name: Get modified containers path
if: |
(github.event.head_commit.author.username == 'bitnami-bot' || github.event.head_commit.author.username == 'fmulero') &&
github.event.forced == false
github.event_name == 'workflow_dispatch' ||
(github.event.head_commit.author.username == 'bitnami-bot' && github.event.forced == false)
outputs:
result: ${{ steps.get-containers.outputs.result }}
containers: ${{ steps.get-containers.outputs.containers }}
@@ -23,7 +30,7 @@ jobs:
- id: get-containers
name: Get modified containers path
env:
GITHUB_COMMITS: ${{ toJson(github.event.commits) }}
GITHUB_COMMITS: ${{ github.event_name == 'workflow_dispatch' && format('[{{"id":"{0}"}}]', inputs.sha) || toJson(github.event.commits) }}
run: |
# Get all commits associated to the push
commits=($(echo "${GITHUB_COMMITS}" | jq -r '.[] | .id'))
@@ -142,27 +149,27 @@ jobs:
ASSET_DATA=(${CLEANED_IMAGE_NAME//-/ })
OS=${ASSET_DATA[0]}-${ASSET_DATA[1]}
REVISION=(${ASSET_DATA[2]/r/})
COMPONENTS_FILES=$(s3cmd ls -l --access_key=${{ secrets.AWS_ACCESS_KEY_ID }} --secret_key=${{ secrets.AWS_SECRET_ACCESS_KEY }} s3://${{ secrets.AWS_S3_BUCKET }}/$ASSET/$VERSION/$OS/$ARCH/$REVISION/ | grep "components.json" | wc -l)
# If the components.json file, so it seems has external packages
if [[ $COMPONENTS_FILES -gt 0 ]]; then
s3cmd get --access_key=${{ secrets.AWS_ACCESS_KEY_ID }} --secret_key=${{ secrets.AWS_SECRET_ACCESS_KEY }} s3://${{ secrets.AWS_S3_BUCKET }}/$ASSET/$VERSION/$OS/$ARCH/$REVISION/components.json components.json
declare -A PACKAGES
# Iterating over the external components to get the involved elements
while read -r COMPONENT_ID; do
COMPONENT_VERSION_FULL=$(jq -c ".$COMPONENT_ID.version" components.json)
COMPONENT_VERSION_FULL=(${COMPONENT_VERSION_FULL//"\""/})
# Sanityzing strings
COMPONENT_ID=(${COMPONENT_ID//"\""/})
#split by "-"
COMPONENT_PARTS=(${COMPONENT_VERSION_FULL//-/ })
COMPONENT_VERSION=${COMPONENT_PARTS[0]}
COMPILATION_RECIPE=$(s3cmd ls -l --access_key=${{ secrets.AWS_ACCESS_KEY_ID }} --secret_key=${{ secrets.AWS_SECRET_ACCESS_KEY }} s3://${{ secrets.AWS_S3_BUCKET }}/$COMPONENT_ID/$COMPONENT_VERSION/$OS/$ARCH/ | grep "compilation-recipe.json" | wc -l)
# If the components.json file, so it seems has external packages
if [[ $COMPILATION_RECIPE -gt 0 ]]; then
if [[ $COMPILATION_RECIPE -gt 0 ]]; then
s3cmd get --access_key=${{ secrets.AWS_ACCESS_KEY_ID }} --secret_key=${{ secrets.AWS_SECRET_ACCESS_KEY }} s3://${{ secrets.AWS_S3_BUCKET }}/$COMPONENT_ID/$COMPONENT_VERSION/$OS/$ARCH/compilation-recipe.json compilation-recipe.json
else
s3cmd get --access_key=${{ secrets.AWS_ACCESS_KEY_ID }} --secret_key=${{ secrets.AWS_SECRET_ACCESS_KEY }} s3://${{ secrets.AWS_S3_BUCKET }}/$COMPONENT_ID/$COMPONENT_VERSION-${COMPONENT_PARTS[1]}/$OS/$ARCH/compilation-recipe.json compilation-recipe.json
@@ -176,7 +183,7 @@ jobs:
done <<<"$(jq -c '.components[]' compilation-recipe.json)"
rm compilation-recipe.json
done <<<"$(jq -c 'keys[]' components.json)"
# Now creating the JSON file with the needed transformations
JSON_PACKAGES=()
for PACKAGE_ID in "${!PACKAGES[@]}"