Merge pull request #2 from firstlovecenter/fix/refresh-token-missing-… #54
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 Auth Lambda to AWS | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| paths: | |
| - "src/**" | |
| - "package.json" | |
| - "tsconfig.json" | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: "Environment to deploy to" | |
| required: true | |
| default: "dev" | |
| type: choice | |
| options: | |
| - dev | |
| - main | |
| jobs: | |
| deploy: | |
| name: Deploy to AWS Lambda | |
| runs-on: ubuntu-latest | |
| environment: production | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Determine deployment target | |
| id: target | |
| run: | | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| echo "FUNCTION_NAME=fl-auth-service-lambda" >> $GITHUB_OUTPUT | |
| echo "ENVIRONMENT=production" >> $GITHUB_OUTPUT | |
| else | |
| echo "FUNCTION_NAME=dev-fl-auth-service-lambda" >> $GITHUB_OUTPUT | |
| echo "ENVIRONMENT=development" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "18" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build TypeScript | |
| run: npm run build | |
| - 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: Prepare Lambda package | |
| run: | | |
| # Create temporary directory for Lambda deployment | |
| mkdir -p lambda-package | |
| # Copy compiled JavaScript files | |
| cp -r dist/* lambda-package/ || true | |
| # Copy package.json for reference | |
| cp package.json lambda-package/ | |
| # Install production dependencies | |
| cd lambda-package | |
| npm install --omit=dev | |
| - name: Create deployment package | |
| run: | | |
| cd lambda-package | |
| zip -r ../auth-lambda.zip . | |
| - name: Deploy Lambda function | |
| run: | | |
| aws lambda update-function-code \ | |
| --function-name ${{ steps.target.outputs.FUNCTION_NAME }} \ | |
| --zip-file fileb://auth-lambda.zip | |
| - name: Verify deployment | |
| run: | | |
| echo "Lambda function deployed successfully!" | |
| aws lambda get-function \ | |
| --function-name ${{ steps.target.outputs.FUNCTION_NAME }} \ | |
| --query 'Configuration.{Name:FunctionName,Runtime:Runtime,LastModified:LastModified}' \ | |
| --output table | |
| - name: Notify deployment status | |
| if: always() | |
| uses: rtCamp/action-slack-notify@v2 | |
| env: | |
| SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
| SLACK_CHANNEL: deployments | |
| SLACK_COLOR: ${{ job.status }} | |
| SLACK_TITLE: "🔐 FL Auth Service Lambda Deployment" | |
| SLACK_MESSAGE: | | |
| Environment: ${{ steps.target.outputs.ENVIRONMENT }} | |
| Function: ${{ steps.target.outputs.FUNCTION_NAME }} | |
| Commit: ${{ github.event.head_commit.message }} | |
| Status: ${{ job.status }} |