[workflows]: Add Continuous Deployment
This commit is contained in:
41
.github/workflows/ci.yml
vendored
41
.github/workflows/ci.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: Continuous Integration
|
||||
name: Continuous Integration / Continuous Deployment
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
@ -67,3 +67,42 @@ jobs:
|
||||
# Show coverage summary in logs
|
||||
- name: Show coverage summary
|
||||
run: cat coverage.xml
|
||||
|
||||
|
||||
# Step 2: Continuous Deployment (CD) - Deploy multiple AWS Lambda functions
|
||||
deploy:
|
||||
needs: test # Ensures deployment happens only if tests pass
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/main' # Deploy only from main branch
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
function_name: [permanent_data, transient_data, return_all_data, return_newest_data, return_luas_data, return_station_data]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.13.1'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -r server/src/requirements.txt -t package/
|
||||
cp -r package/* server/src/functions/${{ matrix.function_name }}/
|
||||
|
||||
- name: Zip Lambda function
|
||||
run: |
|
||||
cd server/src/functions/${{ matrix.function_name }}/
|
||||
zip -r ../../../../${{ matrix.function_name }}.zip . -x "*.git*" "*tests*" "*.github*" "*README.md*" "requirements.txt"
|
||||
|
||||
- name: Deploy to AWS Lambda
|
||||
uses: aws-actions/aws-cli-action@v1
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ secrets.AWS_REGION }}
|
||||
command: |
|
||||
aws lambda update-function-code --function-name ${{ matrix.function_name }} --zip-file fileb://${{ matrix.function_name }}.zip
|
||||
|
Reference in New Issue
Block a user