Skip to content

Commit

Permalink
Create a GitHub action to deploy the ingest inspector (#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
StepanBrychta committed Jul 3, 2024
1 parent cb733c8 commit 5ddff6f
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/deploy-ingest-inspector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Deploy Ingest Inspector
on:
push
# push:
# branches:
# - main

permissions:
id-token: write

jobs:
deploy_ingest_inspector:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-west-1
role-to-assume: ${{ secrets.DEPLOY_INGEST_INSPECTOR_GHA_ROLE_ARN }}
- name: Deploy Ingest Inspector backend
run: |
pip3 install boto3 docopt
python3 ./builds/publish_lambda_zip.py monitoring/ingest_inspector/backend_lambda \
--bucket=wellcomecollection-storage-infra \
--key=lambdas/monitoring/ingest_inspector_backend.zip
./builds/deploy_lambda_zip.sh monitoring/ingest_inspector_backend ingest_inspector_backend
- name: Deploy Ingest Inspector frontend
run: |
cd monitoring/ingest_inspector/frontend
sh deploy.sh
36 changes: 36 additions & 0 deletions builds/deploy_lambda_zip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

# Usage: ./deploy_lambda_zip.sh <project_name> <lambda_name>
# Example: ./deploy_lambda_zip.sh monitoring/ingest_inspector_backend ingest_inspector_backend

set -o errexit
set -o nounset
set -o pipefail

PROJECT_NAME=$1
LAMBDA_NAME=$2

S3_BUCKET="wellcomecollection-storage-infra"
S3_KEY="lambdas/$PROJECT_NAME.zip"

echo "Identifying function: $LAMBDA_NAME"
FUNCTION_ARN=$(aws lambda get-function-configuration \
--function-name $LAMBDA_NAME \
--query "FunctionArn" \
--output text)

echo "Updating function: $FUNCTION_ARN from s3://$S3_BUCKET/$S3_KEY"
REVISION_ID=$(aws lambda update-function-code \
--function-name $LAMBDA_NAME \
--s3-bucket $S3_BUCKET \
--s3-key $S3_KEY \
--query "RevisionId" \
--output text)

echo "Revision id: $REVISION_ID"

echo "Awaiting function update"
aws lambda wait function-updated \
--function-name $LAMBDA_NAME

echo "Done"
2 changes: 1 addition & 1 deletion monitoring/ingest_inspector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,6 @@ The frontend is hosted as a static website on S3 and served via CloudFront. To b
the `ingest_inspector/frontend` directory and run:

```shell
sh deploy.sh
AWS_PROFILE=storage-developer sh deploy.sh
```

5 changes: 4 additions & 1 deletion monitoring/ingest_inspector/frontend/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/sh

echo "Installing packages..."
npm install

echo "Building app..."
npm run build

Expand All @@ -9,7 +12,7 @@ if [ $? -ne 0 ]; then
fi

echo "Uploading to S3..."
AWS_PROFILE=storage-developer aws s3 cp out s3://wellcomecollection-ingest-inspector-frontend --recursive --only-show-errors
aws s3 cp out s3://wellcomecollection-ingest-inspector-frontend --recursive --only-show-errors

if [ $? -eq 0 ]; then
echo "Success!"
Expand Down

0 comments on commit 5ddff6f

Please sign in to comment.