From cfab7e768c241b9b253b14ead45c2587f2ef5777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constan=C3=A7a=20Manteigas?= <113898685+constanca-m@users.noreply.github.com> Date: Thu, 18 Apr 2024 11:48:37 +0200 Subject: [PATCH] Upload dependencies to S3 bucket on new tag release (#689) * Upload dependencies workflow * fix version.py path * Upload dependencies Signed-off-by: constanca --------- Signed-off-by: constanca --- .github/workflows/upload-dependencies.yml | 67 +++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/upload-dependencies.yml diff --git a/.github/workflows/upload-dependencies.yml b/.github/workflows/upload-dependencies.yml new file mode 100644 index 00000000..aa474d4e --- /dev/null +++ b/.github/workflows/upload-dependencies.yml @@ -0,0 +1,67 @@ +--- +## Workflow to push zip with dependencies to S3 bucket every time the ESF version is updated +name: upload-dependencies + +env: + BUCKET_NAME : "esf-dependencies" + AWS_REGION : "eu-central-1" + ROLE: "arn:aws:iam::267093732750:role/esf-dependencies-role" + + +on: + workflow_run: + workflows: [release] + types: + - completed + + +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + + +jobs: + + build-and-upload-dependencies: + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + # See https://docs.aws.amazon.com/lambda/latest/dg/python-package.html#python-package-create-dependencies + + - uses: actions/checkout@v4 + + - name: Get version number + shell: bash + run: | + VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\-[a-zA-Z]+[0-9]+)?' share/version.py) + echo "VERSION=${VERSION}" >> $GITHUB_ENV + echo "::notice::ESF version is $VERSION." + + - uses: actions/setup-python@v5 + with: + python-version: '3.9' + cache: 'pip' # caching pip dependencies + + - name: Install requirements in a directory and zip it. + shell: bash + run: | + pip3 install -r requirements.txt -t ./dependencies + cd dependencies && zip -r ../lambda-v${{ env.VERSION }}.zip . + + - name: Place handlers in the zip file. + shell: bash + run: | + zip -r ./lambda-v${{ env.VERSION }}.zip main_aws.py + zip -r ./lambda-v${{ env.VERSION }}.zip handlers + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ env.ROLE }} + aws-region: ${{ env.AWS_REGION }} + + - name: Copy file to s3 + run: | + aws s3 cp ./lambda-v${{ env.VERSION }}.zip s3://${{ env.BUCKET_NAME }}/ +