Merge develop to QA #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# On merge to qa, build a container and deploy to ECR | |
name: Publish QA | |
on: | |
pull_request: | |
branches: [qa] | |
types: [closed] | |
jobs: | |
publish_and_deploy_qa: | |
name: Publish image to ECR | |
if: github.event.pull_request.merged | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
project: [OE, SE] | |
stage: [cm_scripts_active, cm_webapp_active] | |
include: | |
- project: OE | |
ECR_REPOSITORY: OE_ECR_REPOSITORY | |
AWS_ACCESS_KEY_ID: OE_AWS_ACCESS_KEY_ID | |
AWS_SECRET_ACCESS_KEY: OE_AWS_SECRET_ACCESS_KEY | |
- project: SE | |
ECR_REPOSITORY: SE_ECR_REPOSITORY | |
AWS_ACCESS_KEY_ID: SE_AWS_ACCESS_KEY_ID | |
AWS_SECRET_ACCESS_KEY: SE_AWS_SECRET_ACCESS_KEY | |
- stage: cm_scripts_active | |
container_tag: qa-cron-latest | |
- stage: cm_webapp_active | |
container_tag: qa-latest | |
- project: OE | |
stage: cm_scripts_active | |
cluster_service: OE_SCRIPTS_CLUSTER_SERVICE | |
- project: OE | |
stage: cm_webapp_active | |
cluster_service: OE_WEBAPP_CLUSTER_SERVICE | |
- project: SE | |
stage: cm_scripts_active | |
cluster_service: SE_SCRIPTS_CLUSTER_SERVICE | |
- project: SE | |
stage: cm_webapp_active | |
cluster_service: SE_WEBAPP_CLUSTER_SERVICE | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: Configure QA AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets[matrix.AWS_ACCESS_KEY_ID] }} | |
aws-secret-access-key: ${{ secrets[matrix.AWS_SECRET_ACCESS_KEY] }} | |
aws-region: us-east-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image to Amazon ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ${{ secrets[matrix.ECR_REPOSITORY] }} | |
IMAGE_TAG: ${{ github.sha }} | |
CONTAINER_TAG: ${{ matrix.container_tag }} | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . --target ${{ matrix.stage }} | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$CONTAINER_TAG | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$CONTAINER_TAG | |
- name: Force ECS Update | |
env: | |
cluster_service: ${{ secrets[matrix.cluster_service] }} | |
run: | | |
aws ecs update-service --cluster $cluster_service --service $cluster_service --force-new-deployment |