From ce8200238f298d17c5d8749d2a19f37bd56cdd95 Mon Sep 17 00:00:00 2001 From: Deda Date: Fri, 22 Mar 2024 14:27:39 +0100 Subject: [PATCH] Add validation check for s3_dest_dir if pushing to download.memgraph.com --- .github/workflows/reusable_docker_package.yaml | 12 +++++++++++- .github/workflows/reusable_package.yaml | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable_docker_package.yaml b/.github/workflows/reusable_docker_package.yaml index 082d667de..c15906419 100644 --- a/.github/workflows/reusable_docker_package.yaml +++ b/.github/workflows/reusable_docker_package.yaml @@ -46,7 +46,7 @@ on: s3_region: type: string description: "Region for the target S3 bucket." - default: '' + default: 'eu-west-1' s3_dest_dir: type: string description: "Target dir path in S3 bucket." @@ -134,6 +134,16 @@ jobs: needs: [package] runs-on: ubuntu-latest steps: + - name: Validate dest_dir + if: ${{ inputs.s3_bucket == 'download.memgraph.com' }} + run: | + if ! [[ "${{ inputs.s3_dest_dir }}" =~ memgraph/[0-9]\.[0-9]+\.[0-9]+$ ]]; then + echo -e "Error: ${{ inputs.s3_dest_dir }} is not a valid official format. When pushing to 'download.memgraph.com' the dest dir has to match format 'memgraph/X.Y.Z'!" + exit 1 + else + echo -e "Passed: Dest dir ${{ inputs.s3_dest_dir }} has a valid official format." + fi + - name: Download artifacts uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/reusable_package.yaml b/.github/workflows/reusable_package.yaml index 66071cfe8..b396f52cb 100644 --- a/.github/workflows/reusable_package.yaml +++ b/.github/workflows/reusable_package.yaml @@ -46,7 +46,7 @@ on: s3_region: type: string description: "Region for the target S3 bucket." - default: '' + default: 'eu-west-1' s3_dest_dir: type: string description: "Target dir path in S3 bucket." @@ -129,6 +129,16 @@ jobs: needs: [package] runs-on: ubuntu-latest steps: + - name: Validate dest_dir + if: ${{ inputs.s3_bucket == 'download.memgraph.com' }} + run: | + if ! [[ "${{ inputs.s3_dest_dir }}" =~ memgraph/[0-9]\.[0-9]+\.[0-9]+$ ]]; then + echo -e "Error: ${{ inputs.s3_dest_dir }} is not a valid official format. When pushing to 'download.memgraph.com' the dest dir has to match format 'memgraph/X.Y.Z'!" + exit 1 + else + echo -e "Passed: Dest dir ${{ inputs.s3_dest_dir }} has a valid official format." + fi + - name: Download artifacts uses: actions/download-artifact@v4 with: