Skip to content

Commit

Permalink
Add initial JSON artifact creation and upload, install jq, download J…
Browse files Browse the repository at this point in the history
…SON artifact, append to JSON artifact, and upload updated JSON artifact
  • Loading branch information
FloRul committed Jan 31, 2024
1 parent 85a3a45 commit c82678d
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions .github/workflows/lambda_container_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
on: [push]

jobs:
init:
runs-on: ubuntu-latest
steps:
- name: Create initial JSON artifact
run: |
echo '[]' > image_details.json
- name: Upload initial JSON artifact
uses: actions/upload-artifact@v2
with:
name: image-details
path: image_details.json

build-and-push:
runs-on: ubuntu-latest
strategy:
Expand All @@ -13,6 +26,15 @@ jobs:
'list_collections',
]
steps:
- name: Install and use jq
run: |
sudo apt-get install -y jq
- name: Download JSON artifact
uses: actions/download-artifact@v2
with:
name: image-details

- name: Checkout code
uses: actions/checkout@v2

Expand All @@ -34,7 +56,7 @@ jobs:
- name: Compute hash of source code
id: compute-hash
run: |
echo "INFERENCE_IMAGE=$(tar -cf - ./${{ matrix.lambda_path_ecr }}/src | sha256sum | cut -d ' ' -f 1)" >> $GITHUB_ENV
echo "LAMBDA_IMAGE=$(tar -cf - ./${{ matrix.lambda_path_ecr }}/src | sha256sum | cut -d ' ' -f 1)" >> $GITHUB_ENV
shell: /usr/bin/bash -e {0}

- name: Build, tag, and push image to Amazon ECR
Expand All @@ -43,7 +65,21 @@ jobs:
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ matrix.lambda_path_ecr }}
IMAGE_TAG: ${{ env.INFERENCE_IMAGE }}
IMAGE_TAG: ${{ env.LAMBDA_IMAGE }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Append to JSON artifact
run: |
if [ ! -f image_details.json ]; then
echo '[]' > image_details.json
fi
jq '. += [{"ECR_REGISTRY": "'"$ECR_REGISTRY"'", "ECR_REPOSITORY": "'"$ECR_REPOSITORY"'", "IMAGE_TAG": "'"$IMAGE_TAG"'"}]' image_details.json | sponge image_details.json
- name: Upload updated JSON artifact
uses: actions/upload-artifact@v2
with:
name: image-details
path: image_details.json

0 comments on commit c82678d

Please sign in to comment.