Skip to content

Commit

Permalink
Merge pull request #27 from slacgismo/validation-runner-connect
Browse files Browse the repository at this point in the history
Validation runner connect
  • Loading branch information
Thistleman authored Oct 30, 2023
2 parents 7a0bd2e + 6bd58d6 commit 19d5724
Show file tree
Hide file tree
Showing 43 changed files with 878 additions and 978 deletions.
56 changes: 24 additions & 32 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,18 @@ env:


jobs:
# build-fe:
# name: Build and Test
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# name: Checkout Repository

# - name: install
# run: |
# cd frontend
# export DOCKER_BUILDKIT=1
# docker build -t pv/val:tag -f Dockerfile .

# Needs to include aws login step as well
# - name: build
# run: |
# cd frontend
# npm run build
# aws s3 sync ./build/ s3://pv-validation-hub-website --acl public-read
#
build-fe:
name: Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Checkout Repository

- name: install dependencies and build
run: |
cd frontend
npm install
npm run build
build-api:
name: Build and Test
Expand All @@ -49,15 +41,15 @@ jobs:
export DOCKER_BUILDKIT=1
docker build --build-arg admin_username="placeholder" --build-arg admin_password="replaceme" --build-arg djangosk="placeholder" -t pv/val:tag -f Dockerfile .
# build-worker:
# name: Build and Test
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# name: Checkout Repository

# - name: build
# run: |
# cd workers
# export DOCKER_BUILDKIT=1
# docker build -t pv/val:tag -f Dockerfile .
build-worker:
name: Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Checkout Repository

- name: build
run: |
cd workers
export DOCKER_BUILDKIT=1
docker build -t pv/val:tag -f Dockerfile .
70 changes: 0 additions & 70 deletions .github/workflows/deploy.md

This file was deleted.

151 changes: 151 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: Deploy Production to Amazon ECS

on:
workflow_dispatch:
release:
types: [published]

env:
AWS_REGION: MY_AWS_REGION # set this to your preferred AWS region, e.g. us-west-2
ECR_REPOSITORY: MY_ECR_REPOSITORY # set this to your Amazon ECR repository name
ECS_SERVICE: MY_ECS_SERVICE # set this to your Amazon ECS service name
ECS_CLUSTER: MY_ECS_CLUSTER # set this to your Amazon ECS cluster name
ECS_TASK_DEFINITION: MY_ECS_TASK_DEFINITION # set this to the path to your Amazon ECS task definition
# file, e.g. .aws/task-definition.json
CONTAINER_NAME: MY_CONTAINER_NAME # set this to the name of the container in the
# containerDefinitions section of your task definition

jobs:
deploy_FE:
name: Build and Test
runs-on: ubuntu-latest
environment: production

steps:
- uses: actions/checkout@v2
name: Checkout Repository

- name: install dependencies and build
run: |
cd frontend
npm install
npm run build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Website s3 sync
run: |
aws s3 sync ./frontend/build/ s3://pv-validation-hub-website --acl public-read
- name: Run CF invalidation
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.PROD_CF_ID }} --paths '/*'

deploy_WORKER:
name: Deploy
runs-on: ubuntu-latest
environment: production

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.PROD_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PROD_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

# uses repository in your authorized registry to push to.
# sign in to your ecr page for a list of all your repositories.
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: pv-validation-hub-worker
IMAGE_TAG: latest
run: |
export DOCKER_BUILDKIT=1
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
# needed for the task-definition.json file, update task family here
# can also use the CLI to manually generate the task
- name: Download task definition
run: |
aws ecs describe-task-definition --task-definition openfido-prod-app-task --query taskDefinition > task-definition.json
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: 'openfido-prod-app-task'
image: ${{ steps.build-image.outputs.image }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: 'openfido-prod-app-service'
cluster: 'openfido-prod-ecs-cluster'
wait-for-service-stability: true

deploy_API:
name: Deploy
runs-on: ubuntu-latest
environment: production

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@13d241b293754004c80624b5567555c4a39ffbe3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@aaf69d68aa3fb14c1d5a6be9ac61fe15b48453a2

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@97587c9d45a4930bf0e3da8dd2feb2a463cf4a3a
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@de0132cf8cdedb79975c6d42b77eb7ea193cf28e
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
66 changes: 0 additions & 66 deletions .github/workflows/deploy_dev_to_AWS.md

This file was deleted.

Loading

0 comments on commit 19d5724

Please sign in to comment.