diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/deploy-test.yml new file mode 100644 index 0000000..b229109 --- /dev/null +++ b/.github/workflows/deploy-test.yml @@ -0,0 +1,47 @@ +name: Deploy to AWS Lambda Test + +on: + workflow_dispatch: + +env: + AWS_REGION: ap-northeast-2 + ECR_CRAWL_REPO_NAME: dev/crawl + LAMBDA_FUNCTION_NAME: withins-playwright-crawler-test + +jobs: + deploy: + name: Deploy to AWS Lambda + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ECR_LAMBDA_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_ECR_LAMBDA_SECRET_ACCESS_KEY_ID }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Build and push Docker image + id: build-image + env: + REGISTRY: ${{ steps.login-ecr.outputs.registry }} + REPOSITORY: ${{ env.ECR_CRAWL_REPO_NAME }} + IMAGE_TAG: ${{ github.sha }} + run: | + IMAGE_URI=$REGISTRY/$REPOSITORY:$IMAGE_TAG + docker build -t $IMAGE_URI . + docker push $IMAGE_URI + echo "image-uri=$IMAGE_URI" >> $GITHUB_OUTPUT + + - name: Deploy to Lambda + uses: int128/deploy-lambda-action@v1 + with: + function-name: ${{ env.LAMBDA_FUNCTION_NAME }} + image-uri: ${{ steps.build-image.outputs.image-uri }} \ No newline at end of file