From e816896740659e6cd11d1cd21b37d229b48ab254 Mon Sep 17 00:00:00 2001 From: Fran Mulero Date: Tue, 24 Jan 2023 10:45:25 +0100 Subject: [PATCH] [bitnami/containers] Feature: retry CD pipeline manually (#21545) Signed-off-by: Fran Mulero Signed-off-by: Fran Mulero --- .github/workflows/cd-pipeline.yml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cd-pipeline.yml b/.github/workflows/cd-pipeline.yml index cfa9bd107c65..3bef6a910a19 100644 --- a/.github/workflows/cd-pipeline.yml +++ b/.github/workflows/cd-pipeline.yml @@ -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[@]}"