debug process forwarded message #93
This file contains hidden or 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
name: Deploy Lambda to S3 and Update Function | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "src/**" | |
- ".github/**" | |
- "requirements.txt" | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
env: | |
AWS_REGION: eu-central-1 | |
S3_BUCKET: mirrowchanbot-code-bucket | |
LAMBDA_FUNCTION_NAME: mirrowchanbot-handler | |
LAMBDA_ZIP_KEY: mirrowchanbot/code.zip | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Install dependencies in package folder | |
run: | | |
python -m pip install --upgrade pip | |
mkdir package | |
pip install requests -t package/ | |
- name: Prepare Lambda ZIP | |
run: | | |
cd src | |
zip -r9 ../lambda.zip . -x "*/__pycache__/*" "*.pyc" | |
cd ../package | |
zip -r9 ../lambda.zip . | |
- name: Upload to S3 | |
run: | | |
aws s3 cp lambda.zip s3://$S3_BUCKET/$LAMBDA_ZIP_KEY | |
- name: Update Lambda function code | |
run: | | |
aws lambda update-function-code \ | |
--function-name $LAMBDA_FUNCTION_NAME \ | |
--s3-bucket $S3_BUCKET \ | |
--s3-key $LAMBDA_ZIP_KEY | |
- name: Optional Clean up | |
run: rm lambda.zip |