add o1-mini #28
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: Update AWS Lambda Function | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
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: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/arm64 | |
provenance: false | |
push: true | |
tags: | | |
${{ steps.login-ecr.outputs.registry }}/slackbot:${{ github.sha }} | |
${{ steps.login-ecr.outputs.registry }}/slackbot:latest | |
- name: Update Lambda Function | |
env: | |
FUNCTION_NAME: slackbot3 | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: slackbot | |
IMAGE_TAG: ${{ github.sha }} | |
run: | | |
aws lambda update-function-code \ | |
--function-name $FUNCTION_NAME \ | |
--image-uri $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
# TODO: Try something like below to avoid rebuilding when packages don't change | |
# - name: Get last successful deployment | |
# id: last_deploy | |
# run: | | |
# LAST_TAG=$(git describe --tags --abbrev=0 --match "deploy-*" 2>/dev/null || echo "") | |
# echo "last_tag=$LAST_TAG" >> $GITHUB_OUTPUT | |
# - name: Check if requirements.txt has changed | |
# id: check_requirements | |
# run: | | |
# LAST_TAG=${{ steps.last_deploy.outputs.last_tag }} | |
# if [ -z "$LAST_TAG" ]; then | |
# echo "requirements_changed=true" >> $GITHUB_OUTPUT | |
# else | |
# CHANGED=$(git diff $LAST_TAG..HEAD --name-only | grep -q "requirements.txt" && echo "true" || echo "false") | |
# echo "requirements_changed=$CHANGED" >> $GITHUB_OUTPUT | |
# fi | |
# - name: Build and push | |
# uses: docker/build-push-action@v4 | |
# with: | |
# context: . | |
# platforms: linux/arm64 | |
# provenance: false | |
# push: true | |
# file: ${{ steps.check_requirements.outputs.requirements_changed == 'true' && 'Dockerfile' || 'Dockerfile_v2' }} | |
# tags: | | |
# ${{ steps.login-ecr.outputs.registry }}/slackbot:${{ github.sha }} | |
# ${{ steps.login-ecr.outputs.registry }}/slackbot:latest | |
# - name: Tag successful deployment | |
# if: success() | |
# run: | | |
# git config user.name github-actions | |
# git config user.email [email protected] | |
# git tag -a "deploy-${{ github.sha }}" -m "Successful deployment" | |
# git push origin "deploy-${{ github.sha }}" |