Merge pull request #101 from ViLsonCake/fix-delay-notification-duplic… #19
This file contains hidden or 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 flights-notification-lambda | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'flights-notification-lambda/**' | |
| - 'common-library/**' | |
| - '.github/workflows/deploy-flights-notification-lambda.yml' | |
| jobs: | |
| deploy: | |
| name: Build and Deploy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Java 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: 'gradle' | |
| - name: Build JAR | |
| working-directory: flights-notification-lambda | |
| run: ./gradlew shadowJar | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: Upload JAR to S3 | |
| run: | | |
| aws s3 cp \ | |
| flights-notification-lambda/build/libs/flights-notification-lambda.jar \ | |
| s3://${{ secrets.LAMBDA_BUCKET }}/flights-notification-lambda.jar | |
| - name: Deploy to Lambda | |
| run: | | |
| aws lambda update-function-code \ | |
| --function-name aviation-telegram-bot-flights-notification \ | |
| --s3-bucket ${{ secrets.LAMBDA_BUCKET }} \ | |
| --s3-key flights-notification-lambda.jar | |
| - name: Wait for Lambda Update | |
| run: | | |
| aws lambda wait function-updated \ | |
| --function-name aviation-telegram-bot-flights-notification | |
| - name: Set Lambda Environment Variables | |
| env: | |
| BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | |
| DB_HOST: ${{ secrets.DB_HOST }} | |
| DB_NAME: ${{ secrets.DB_NAME }} | |
| DB_USERNAME: ${{ secrets.DB_USERNAME }} | |
| DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| FLIGHTRADAR_API_LAMBDA_NAME: aviation-telegram-bot-flightradar-api-get-scheduled-flights | |
| run: | | |
| aws lambda update-function-configuration \ | |
| --function-name aviation-telegram-bot-flights-notification \ | |
| --environment "$(jq -n '{Variables: { | |
| BOT_TOKEN: env.BOT_TOKEN, | |
| DB_HOST: env.DB_HOST, | |
| DB_NAME: env.DB_NAME, | |
| DB_USERNAME: env.DB_USERNAME, | |
| DB_PASSWORD: env.DB_PASSWORD, | |
| FLIGHTRADAR_API_LAMBDA_NAME: env.FLIGHTRADAR_API_LAMBDA_NAME | |
| }}')" |