Skip to content

Commit

Permalink
Upload dependencies to S3 bucket on new tag release (#689)
Browse files Browse the repository at this point in the history
* Upload dependencies workflow

* fix version.py path

* Upload dependencies

Signed-off-by: constanca <[email protected]>

---------

Signed-off-by: constanca <[email protected]>
  • Loading branch information
constanca-m authored Apr 18, 2024
1 parent 374e966 commit cfab7e7
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/upload-dependencies.yml
Original file line number Diff line number Diff line change
@@ -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 }}/

0 comments on commit cfab7e7

Please sign in to comment.