Skip to content

Merge pull request #2 from selmaohneh/develop #39

Merge pull request #2 from selmaohneh/develop

Merge pull request #2 from selmaohneh/develop #39

Workflow file for this run

name: Build, Test, Package and ZIP .NET 6 Lambda Functions
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
env:
ProjectBasePath: 'LolChest.Lambda'
strategy:
matrix:
project: ['DailyReport', 'MonthlyReport', 'YearlyReport', 'Update']
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Restore Dependencies
run: dotnet restore $ProjectBasePath.${{ matrix.project }}
- name: Build
run: dotnet build --configuration Release --no-restore $ProjectBasePath.${{ matrix.project }}
- name: Test
run: dotnet test --no-restore --verbosity normal $ProjectBasePath.${{ matrix.project }}
- name: Publish
run: dotnet publish --configuration Release --no-build --output ./publish $ProjectBasePath.${{ matrix.project }}
- name: Create ZIP
run: |
cd ./publish
zip -r ../${{ matrix.project }}.zip *
- name: Upload ZIP
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.project }}
path: ./${{ matrix.project }}.zip
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
if: github.ref == 'refs/heads/master'
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- name: Deploy to AWS Lambda
if: github.ref == 'refs/heads/master'
run: |
aws lambda update-function-code --function-name ${{ matrix.project }} --zip-file fileb://./${{ matrix.project }}.zip
- name: Wait for deployment to complete
if: github.ref == 'refs/heads/master'
run: sleep 30
- name: Update function configuration
if: github.ref == 'refs/heads/master'
run: |
aws lambda update-function-configuration --function-name ${{ matrix.project }} --handler $ProjectBasePath.${{ matrix.project }}::$ProjectBasePath.${{ matrix.project }}.Function::FunctionHandler --environment 'Variables={AwsAccessKey=${{ secrets.AWS_ACCESS_KEY_ID }},AwsSecretKey=${{ secrets.AWS_SECRET_ACCESS_KEY }},AwsBucketName=${{ secrets.AwsBucketName }},AwsRegion=${{ secrets.AwsRegion }},EmailAddresses=${{ secrets.EmailAddresses }},RiotGamesApiKey=${{ secrets.RiotGamesApiKey }},PlatformRoute=${{ secrets.PlatformRoute }},RegionalRoute=${{ secrets.RegionalRoute }},SummonerNames=${{ secrets.SummonerNames }}}' --timeout 30