Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload dependencies to S3 bucket on new tag release #689

Merged
merged 5 commits into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps get the tag from git, to avoid duplicating this logic across multiple workflows? e.g. we could use git describe to get the tag for the current branch.

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 }}/

Loading