🧩 Serverless deployment to AWS #10
This file contains 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: "🧩 Serverless deployment to AWS" | |
permissions: | |
contents: read | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- "*.yml" | |
env: | |
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" | |
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" | |
jobs: | |
deploy: | |
name: "deploy" | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
- name: "Get latest lambda tags from AWS ECR" | |
id: "lambda-verions" | |
run: | | |
echo "DATA_PREPROCESSING_VERSION=$(aws ecr describe-images \ | |
--output json \ | |
--repository-name mlops-data-preprocessing \ | |
--query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' \ | |
| jq . --raw-output)" \ | |
>> "$GITHUB_OUTPUT" | |
echo "MODEL_TRAINING_VERSION=$(aws ecr describe-images \ | |
--output json \ | |
--repository-name mlops-model-training \ | |
--query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' \ | |
| jq . --raw-output)" \ | |
>> "$GITHUB_OUTPUT" | |
echo "MODEL_DEPLOYMENT_VERSION=$(aws ecr describe-images \ | |
--output json \ | |
--repository-name mlops-model-deployment \ | |
--query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' \ | |
| jq . --raw-output)" \ | |
>> "$GITHUB_OUTPUT" | |
- name: "Serverless deployment" | |
uses: serverless/github-action@189dd6854a3b12ecff4a02c49351779f919933ca | |
with: | |
args: -c "serverless plugin install --name serverless-iam-roles-per-function && serverless deploy" | |
entrypoint: /bin/sh | |
env: | |
DATA_PREPROCESSING_VERSION: ${{ steps.lambda-verions.outputs.DATA_PREPROCESSING_VERSION }} | |
MODEL_TRAINING_VERSION: ${{ steps.lambda-verions.outputs.MODEL_TRAINING_VERSION }} | |
MODEL_DEPLOYMENT_VERSION: ${{ steps.lambda-verions.outputs.MODEL_DEPLOYMENT_VERSION }} |