From 0a999b8a7c1159088ce213b2abd373959ae8749d Mon Sep 17 00:00:00 2001 From: Ru Chern Chong Date: Sat, 4 May 2024 03:36:41 +0800 Subject: [PATCH] Add GitHub Actions workflow --- .github/workflows/Deploy.yml | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/Deploy.yml diff --git a/.github/workflows/Deploy.yml b/.github/workflows/Deploy.yml new file mode 100644 index 0000000..a9674a6 --- /dev/null +++ b/.github/workflows/Deploy.yml @@ -0,0 +1,47 @@ +name: Deploy to AWS Lambda + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + environment: Preview + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - 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 + run: | + zip -r 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 to AWS Lambda - Preview + run: | + aws lambda update-function-code --function-name dev-lta-datasets-updater --zip-file fileb://deployment_package.zip \ No newline at end of file