feat: ✨ Add CORSMiddleware #5
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
name: CI/CD | |
on: | |
push: | |
pull_request: | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
name: Checkout | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
name: Set up Python | |
with: | |
python-version: '3.13' | |
- uses: pre-commit/action@v3.0.0 | |
name: Run pre-commit | |
with: | |
extra_args: --all-files | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
name: Checkout | |
- uses: actions/setup-python@v4 | |
name: Set up Python | |
with: | |
python-version: '3.13' | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
- name: Install dependencies | |
run: poetry install --with dev --no-root | |
- name: Run tests | |
run: poetry run pytest | |
deploy: | |
needs: [pre-commit, test] | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
name: Checkout | |
- uses: actions/setup-python@v4 | |
name: Set up Python | |
with: | |
python-version: '3.13' | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
poetry self add poetry-plugin-export | |
- name: Create deployment package | |
run: | | |
mkdir package | |
cd package | |
poetry export --with lambda --without-hashes -f requirements.txt -o requirements.txt | |
pip install -r requirements.txt --target . | |
cp -r ../src . | |
zip -r ../api.zip . | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
- name: Upload to S3 | |
run: aws s3 cp api.zip s3://movgr-api/api.zip | |
- name: Deploy Lambda | |
run: aws lambda update-function-code --function-name movgr-api --s3-bucket movgr-api --s3-key api.zip |