fix: try make AWS_ACCOUNT_ID visible #4
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 Lambda Service | |
| on: | |
| push: | |
| branches: [ master, main ] | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ vars.AWS_REGION }} | |
| - name: Login to Amazon ECR | |
| uses: aws-actions/amazon-ecr-login@v1 | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| file: ./Dockerfile.lambda | |
| platforms: linux/arm64 | |
| push: true | |
| tags: | | |
| ${{ vars.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com/${{ vars.ECR_REPOSITORY }}:latest | |
| ${{ vars.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com/${{ vars.ECR_REPOSITORY }}:${{ github.sha }} | |
| - name: Update Lambda function | |
| run: | | |
| # Construct URI directly from variables to avoid masking | |
| IMAGE_URI="${{ vars.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com/${{ vars.ECR_REPOSITORY }}:latest" | |
| # Force ARM64 architecture to prevent manifest errors | |
| aws lambda update-function-configuration \ | |
| --function-name ${{ vars.LAMBDA_FUNCTION_NAME }} \ | |
| --architectures arm64 \ | |
| --region ${{ vars.AWS_REGION }} | |
| # Update function with visible URI | |
| echo "Updating Lambda with image: $IMAGE_URI" | |
| aws lambda update-function-code \ | |
| --function-name ${{ vars.LAMBDA_FUNCTION_NAME }} \ | |
| --image-uri "$IMAGE_URI" \ | |
| --region ${{ vars.AWS_REGION }} | |
| - name: Test Lambda function | |
| run: | | |
| VISIBLE_URI="${{ vars.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com/${{ vars.ECR_REPOSITORY }}:latest" | |
| echo "Lambda function updated successfully!" | |
| echo "Image deployed: $VISIBLE_URI" | |
| echo "Function URL: $(aws lambda get-function-url-config --function-name ${{ vars.LAMBDA_FUNCTION_NAME }} --query 'FunctionUrl' --output text --region ${{ vars.AWS_REGION }} || echo 'No function URL configured')" |