From 371208f6f527dd0dd7ddea29b26e074ad566c10e Mon Sep 17 00:00:00 2001 From: Ru Chern Chong Date: Mon, 20 May 2024 03:38:09 +0800 Subject: [PATCH] Update GHA workflow for test and deployment --- .github/workflows/pulumi.preview.yml | 66 ++++++++++++---------------- 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/.github/workflows/pulumi.preview.yml b/.github/workflows/pulumi.preview.yml index c15a6f4..c5f86db 100644 --- a/.github/workflows/pulumi.preview.yml +++ b/.github/workflows/pulumi.preview.yml @@ -3,7 +3,8 @@ name: Preview Deployment on: push: branches: - - main + - "*" + - !main jobs: test: @@ -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 @@ -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 \ No newline at end of file + # - name: Deploy + # run: | + # aws lambda update-function-code --function-name dev-lta-datasets-updater --zip-file fileb://deployment_package.zip \ No newline at end of file