Skip to content

Merge pull request #2114 from LibraryOfCongress/CONCD-482-rsar-tutori… #21

Merge pull request #2114 from LibraryOfCongress/CONCD-482-rsar-tutori…

Merge pull request #2114 from LibraryOfCongress/CONCD-482-rsar-tutori… #21

name: 'Deploy feature branch to test'
on:
workflow_dispatch:
push:
branches: ['feature-*']
paths-ignore:
- docs/**
- README.md
- .github/**
env:
AWS_REGION: us-east-1
permissions:
id-token: write
contents: read
jobs:
deploy:
name: Deploy Feature Branch to Test
runs-on: ubuntu-latest
environment:
name: feature
steps:
- name: Install system packages
run: |
sudo apt-get update -qy && sudo apt-get dist-upgrade -qy && sudo apt-get install -qy \
libmemcached-dev libz-dev libfreetype6-dev libtiff-dev \
libjpeg-dev libopenjp2-7-dev libwebp-dev zlib1g-dev libpq-dev
- name: Install node and npm
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ vars.FEATURE_BRANCH }}
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
git describe --tags
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.10'
# Optional - x64 or x86 architecture, defaults to x64
architecture: 'x64'
- name: Initialize venv install Dependencies
id: python-build
run: |
python3 -m venv venv-1
source venv-1//bin/activate
python3 -m pip install --upgrade pip
pip3 install -U packaging
pip3 install -U setuptools
pip3 install -U pipenv
pipenv install --dev --system --deploy
FULL_VERSION_NUMBER="$(python3 setup.py --version)"
echo "version_number=$(echo "${FULL_VERSION_NUMBER}" | cut -d '+' -f 1)" >> $GITHUB_ENV
python3 setup.py build
- 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: ${{ env.AWS_REGION }}
role-session-name: github_to_aws_deploy
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Build, tag and push docker images ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ secrets.IMAGE_TAG }}
CLUSTER: ${{ secrets.CLUSTER_TEST }}
TARGET_SERVICE: ${{ secrets.TARGET_SERVICE }}
run: |
echo "version number: $version_number"
docker build -t concordia .
docker tag concordia:latest $REGISTRY/concordia:$version_number
docker tag concordia:latest $REGISTRY/concordia:$IMAGE_TAG
docker push $REGISTRY/concordia:$version_number
docker push $REGISTRY/concordia:$IMAGE_TAG
docker build -t concordia/importer --file importer/Dockerfile .
docker tag concordia/importer:latest $REGISTRY/concordia/importer:$version_number
docker tag concordia/importer:latest $REGISTRY/concordia/importer:$IMAGE_TAG
docker push $REGISTRY/concordia/importer:$version_number
docker push $REGISTRY/concordia/importer:$IMAGE_TAG
docker build -t concordia/celerybeat --file celerybeat/Dockerfile .
docker tag concordia/celerybeat:latest $REGISTRY/concordia/celerybeat:$version_number
docker tag concordia/celerybeat:latest $REGISTRY/concordia/celerybeat:$IMAGE_TAG
docker push $REGISTRY/concordia/celerybeat:$version_number
docker push $REGISTRY/concordia/celerybeat:$IMAGE_TAG
aws ecs update-service --region ${{ env.AWS_REGION }} --force-new-deployment --cluster $CLUSTER --service $TARGET_SERVICE