diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..252d6be --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,51 @@ +name: Deploy + +on: + push: + branches: + - development + - base + +jobs: + deploy: + runs-on: ubuntu-latest + + environment: + name: ${{ github.ref_name }} + + env: + LAMBDA_NAME: digitized_image_trigger + LAMBDA_HANDLER_CODE: src/handle_digitized_image_trigger.py + BASENAME: handle_digitized_image_trigger.py + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Export secrets to environment variables + uses: oNaiPs/secrets-to-env-action@v1.5 + with: + secrets: ${{ toJSON(secrets) }} + + - name: Make zip file + run: | + cp ${{ env.LAMBDA_HANDLER_CODE }} ${{ env.BASENAME }} + zip ${{ env.LAMBDA_NAME }}.zip ${{ env.BASENAME }} + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_DEPLOY_ROLE }} + role-skip-session-tagging: true + role-duration-seconds: 900 + + - name: Upload file to S3 + run: aws s3 cp $LAMBDA_NAME.zip s3://${{ secrets.LAMBDA_BUCKET_NAME }}/$LAMBDA_NAME.zip + + - name: Deploy lambda package + run: aws lambda update-function-code + --function-name arn:aws:lambda:${{ secrets.AWS_REGION }}:${{ secrets.AWS_LAMBDA_ACCOUNT_ID }}:function:$LAMBDA_NAME + --zip-file fileb://$LAMBDA_NAME.zip diff --git a/.github/workflows/enforcer.yml b/.github/workflows/enforcer.yml new file mode 100644 index 0000000..1fc567f --- /dev/null +++ b/.github/workflows/enforcer.yml @@ -0,0 +1,16 @@ +name: 'Check Branch' + +on: + pull_request: + branches: + - base + +jobs: + check_branch: + runs-on: ubuntu-latest + steps: + - name: Check branch + if: github.head_ref != 'development' + run: | + echo "ERROR: You can only merge to base from the development branch." + exit 1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..ca2f3bb --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,28 @@ +name: Tests + +on: + pull_request: + branches: + - development + +jobs: + build: + runs-on: ubuntu-latest + + environment: + name: development + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install dependencies + run: pip install tox + + - name: Run tests + run: tox diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bd20e88..0000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -dist: jammy -language: python -python: - - "3.11" -cache: pip -env: - global: - - LAMBDA_NAME: digitized_image_trigger - -before_script: - - pip install tox - -script: tox - -before_deploy: - - pip install awscli - - if [ ! -d deploy_scripts ]; then git clone https://github.com/RockefellerArchiveCenter/deploy_scripts.git; fi - - sudo deploy_scripts/make_zip_lambda.sh ${LAMBDA_NAME} src/handle_digitized_image_trigger.py - -deploy: - - provider: script - script: >- - bash deploy_scripts/upload_file_to_s3.sh ${LAMBDA_NAME}.zip rac-dev-lambda && - bash deploy_scripts/deploy_package_lambda.sh ${LAMBDA_NAME} - skip_cleanup: true - on: - branch: development - - provider: script - script: >- - bash deploy_scripts/upload_file_to_s3.sh ${LAMBDA_NAME}.zip rac-prod-lambda && - bash deploy_scripts/deploy_package_lambda.sh ${LAMBDA_NAME} - skip_cleanup: true - on: - branch: base - -notifications: - email: false diff --git a/README.md b/README.md index 2934a4b..b4ef522 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # digitized_image_trigger Invokes AWS Elastic Container Service (ECS) tasks when objects are created in S3 buckets. -[![Build Status](https://app.travis-ci.com/RockefellerArchiveCenter/digitized_image_trigger.svg?branch=base)](https://app.travis-ci.com/RockefellerArchiveCenter/digitized_image_trigger) - ## Getting Started With [git](https://git-scm.com/) installed, pull down the source code and move into the newly created directory: @@ -18,7 +16,7 @@ This repository is intended to be deployed as a Lambda script in AWS infrastruct ### Expected Message Format -The script is designed to consume messages from an AWS S3 Bucket or an AWS Simple Notifications Service (SNS) queue. +The script is designed to consume messages from an AWS S3 Bucket or an AWS Simple Notifications Service (SNS) queue. SNS messages are expected have the following attributes: - `format` - the format of the package (audio or video)