Skip to content

Commit

Permalink
Update GHA workflow for test and deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Ru Chern Chong committed May 19, 2024
1 parent 4d12cdd commit 371208f
Showing 1 changed file with 28 additions and 38 deletions.
66 changes: 28 additions & 38 deletions .github/workflows/pulumi.preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Preview Deployment
on:
push:
branches:
- main
- "*"
- !main

jobs:
test:
Expand All @@ -12,26 +13,18 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
python-version: 3.12
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- run: pip install -r requirements.txt
- name: Run tests
run: pytest

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

deploy:
runs-on: ubuntu-latest
environment: Preview
Expand All @@ -43,33 +36,30 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
python-version: 3.12
cache: 'pip'

- name: Install AWS CLI
run: |
sudo apt-get install -y awscli
- name: Configure AWS credentials
run: |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws configure set region ${{ vars.AWS_REGION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Package application
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.AWS_REGION }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- run: pip install -r requirements.txt
- name: Create Package for AWS Lambda Layer
run: |
zip -r deployment_package.zip .
zip -r package.zip python/lib/python3.12/site-packages
- uses: pulumi/actions@v5
with:
command: up
stack-name: staging
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}

# - name: Deploy to AWS Lambda - Production
# if: env.ENVIRONMENT == 'Production'
# run: |
# aws lambda update-function-code --function-name prod-lta-datasets-updater --zip-file fileb://deployment_package.zip
# - name: Deploy to AWS Lambda - Production
# if: env.ENVIRONMENT == 'Production'
# run: |
# aws lambda update-function-code --function-name prod-lta-datasets-updater --zip-file fileb://deployment_package.zip

- name: Deploy
run: |
aws lambda update-function-code --function-name dev-lta-datasets-updater --zip-file fileb://deployment_package.zip
# - name: Deploy
# run: |
# aws lambda update-function-code --function-name dev-lta-datasets-updater --zip-file fileb://deployment_package.zip

0 comments on commit 371208f

Please sign in to comment.