From 118fec54f6698d56563d8a92d2a7cd88ba50d142 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 1 Sep 2023 14:51:13 +0100 Subject: [PATCH] testing streamlined approach to pushing and caching in github actions --- .github/workflows/deploy_sap_model_lambda.yml | 33 +++++-------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/.github/workflows/deploy_sap_model_lambda.yml b/.github/workflows/deploy_sap_model_lambda.yml index c9be9083..113a3ecf 100644 --- a/.github/workflows/deploy_sap_model_lambda.yml +++ b/.github/workflows/deploy_sap_model_lambda.yml @@ -22,10 +22,6 @@ jobs: npm install -g serverless npm install -g serverless-domain-manager - - name: Install dependencies - run: | - python -m pip install --upgrade pip - - name: AWS credentials for dev if: github.ref == 'refs/heads/dev' uses: aws-actions/configure-aws-credentials@v1 @@ -54,28 +50,15 @@ jobs: - name: Setup Docker uses: docker/setup-buildx-action@v1 - - name: Cache Docker layers - uses: actions/cache@v2 + # Building and pushing Docker image with caching + - name: Build and push Docker image + uses: docker/build-push-action@v4 with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - - name: Build Docker Image - run: | - cd model_data/simulation_system - docker buildx create --use - docker buildx build --load --cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,dest=/tmp/.buildx-cache --build-arg BUILDKIT_INLINE_CACHE=1 --tag lambda-sap-prediction-image:${{ github.sha }} -f Dockerfiles/Dockerfile.prediction.lambda . - - - name: Login to ECR - run: | - aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin ${{ steps.set_ecr_credentials.outputs.ecr_uri }} - - - name: Tag and Push Docker Image to ECR - run: | - docker tag lambda-sap-prediction-image:${{ github.sha }} ${{ steps.set_ecr_credentials.outputs.ecr_uri }}:${{ github.sha }} - docker push ${{ steps.set_ecr_credentials.outputs.ecr_uri }}:${{ github.sha }} + context: ./model_data/simulation_system + push: true + tags: ${{ steps.set_ecr_credentials.outputs.ecr_uri }}:${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max - name: Deploy to AWS Lambda via Serverless env: