-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upload dependencies to S3 bucket on new tag release (#689)
* Upload dependencies workflow * fix version.py path * Upload dependencies Signed-off-by: constanca <[email protected]> --------- Signed-off-by: constanca <[email protected]>
- Loading branch information
1 parent
374e966
commit cfab7e7
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}/ | ||