feat: updates to code #10
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: Deploy Zappa to AWS | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Deploy with Zappa | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
# Step 1: Check out code | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
# Step 2: Set up Python version | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
# Step 3: Install Dependencies | |
- name: Install Dependencies | |
run: | | |
python -m venv .venv | |
source .venv/bin/activate | |
pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install zappa | |
# Step 4: Create AWS Profile (Explicit Configuration) | |
- name: Create AWS Profile | |
run: | | |
mkdir -p ~/.aws | |
echo "[default]" > ~/.aws/credentials | |
echo "aws_access_key_id=${{ secrets.AWS_ACCESS_KEY_ID }}" >> ~/.aws/credentials | |
echo "aws_secret_access_key=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> ~/.aws/credentials | |
echo "[default]" > ~/.aws/config | |
echo "region = ${{ secrets.AWS_REGION }}" >> ~/.aws/config | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} | |
# Step 5: Validate AWS Credentials and Profile | |
- name: Validate AWS Configuration | |
run: | | |
aws configure list | |
aws sts get-caller-identity | |
# Step 6: Deploy/Update Zappa | |
- name: Deploy to AWS Lambda with Zappa | |
run: | | |
source .venv/bin/activate | |
zappa deploy dev || zappa update dev |