Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 90 additions & 87 deletions .github/workflows/aws-frontend-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@ on:
env:
type: choice
description: 'AWS Incubator Env'
options:
- dev
- prod
options:
- dev
- prod
ref:
description: 'Branch, Tag, or SHA'
required: true
env:
AWS_SHARED_CLUSTER: incubator-prod
AWS_APP_NAME: vrms-client
AWS_APP_NAME: vrms-frontend # vrms-frontend
AWS_REGION: us-west-2
DOCKERFILE: client/Dockerfile.prod
DOCKERFILE: client/Dockerfile.prod # Dockerfile.prod
DOCKER_PATH: client
jobs:
setup_env:
name: Set-up environment
name: Set-up environment
runs-on: ubuntu-latest
steps:
- name: Debug Action
uses: hmarr/debug-action@v2
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref }}
- name: Set AWS Env & Image Tag per workflow
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
INPUT_ENV=${{ github.event.inputs.env }}; INPUT_REF=${{ github.event.inputs.ref }}
echo AWS_APPENV="$AWS_APP_NAME"-$INPUT_ENV >> $GITHUB_ENV
echo IMAGE_TAG=$SHORT_SHA >> $GITHUB_ENV
fi
- name: Debug Action
uses: hmarr/debug-action@v2
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
- name: Set AWS Env & Image Tag per workflow
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
INPUT_ENV=${{ github.event.inputs.env }}; INPUT_REF=${{ github.event.inputs.ref }}
echo AWS_APPENV="$AWS_APP_NAME"-$INPUT_ENV >> $GITHUB_ENV
echo IMAGE_TAG=$SHORT_SHA >> $GITHUB_ENV
fi
outputs:
AWS_APPENV: ${{ env.AWS_APPENV }}
IMAGE_TAG: ${{ env.IMAGE_TAG }}
Expand All @@ -44,75 +44,78 @@ jobs:
runs-on: ubuntu-latest
needs: [setup_env]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref }}
- name: Checkout
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.INCUBATOR_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.INCUBATOR_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Init Docker Cache
uses: jpribyl/[email protected]
with:
key: ${{ github.workflow }}-2-{hash}
restore-keys: |
${{ github.workflow }}-2-
- name: Build & Push Image to ECR
uses: kciter/aws-ecr-action@v3
with:
access_key_id: ${{ secrets.INCUBATOR_AWS_ACCESS_KEY_ID }}
secret_access_key: ${{ secrets.INCUBATOR_AWS_SECRET_ACCESS_KEY }}
account_id: ${{ secrets.INCUBATOR_AWS_ACCOUNT_ID }}
repo: ${{ needs.setup_env.outputs.AWS_APPENV }}
region: ${{ env.AWS_REGION }}
tags: latest,${{ needs.setup_env.outputs.IMAGE_TAG }}
dockerfile: ${{ env.DOCKERFILE }}
path: ${{ env.DOCKER_PATH }}
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref }}
- name: Checkout
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.INCUBATOR_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.INCUBATOR_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
# role-to-assume: arn:aws:iam::035866691871:role/incubator-cicd-vrms
# role-session-name: incubator-cicd-vrms-gha
# aws-region: us-west-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Init Docker Cache
uses: jpribyl/[email protected]
with:
key: ${{ github.workflow }}-2-{hash}
restore-keys: |
${{ github.workflow }}-2-
- name: Build & Push Image to ECR
uses: kciter/aws-ecr-action@v3
with:
access_key_id: ${{ secrets.INCUBATOR_AWS_ACCESS_KEY_ID }}
secret_access_key: ${{ secrets.INCUBATOR_AWS_SECRET_ACCESS_KEY }}
account_id: ${{ secrets.INCUBATOR_AWS_ACCOUNT_ID }}
repo: ${{ needs.setup_env.outputs.AWS_APPENV }}
region: ${{ env.AWS_REGION }}
tags: latest,${{ needs.setup_env.outputs.IMAGE_TAG }}
dockerfile: ${{ env.DOCKERFILE }}
path: ${{ env.DOCKER_PATH }}
deploy:
name: Deploy to AWS ECS
runs-on: ubuntu-latest
needs: [setup_env, build]
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.INCUBATOR_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.INCUBATOR_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Pull Task Definition & write to file
id: aws-task-definition
run: |
aws ecs describe-task-definition \
--task-definition ${{ needs.setup_env.outputs.AWS_APPENV }} \
--query taskDefinition | \
jq 'del(.taskDefinitionArn,.revision,.status,.registeredBy,.registeredAt,.compatibilities,.requiresAttributes)' > task-def.json
- name: Interpolate new Docker Image into Task Definition
id: task-definition
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-def.json
container-name: ${{ needs.setup_env.outputs.AWS_APPENV }}
image: ${{ steps.login-ecr.outputs.registry }}/${{ needs.setup_env.outputs.AWS_APPENV }}:${{ needs.setup_env.outputs.IMAGE_TAG }}
- name: Deploy Amazon ECS
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-definition.outputs.task-definition }}
service: ${{ needs.setup_env.outputs.AWS_APPENV }}
cluster: ${{ env.AWS_SHARED_CLUSTER }}
wait-for-service-stability: true
wait-for-minutes: 5 minutes

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.INCUBATOR_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.INCUBATOR_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Pull Task Definition & write to file
id: aws-task-definition
run: |
aws ecs describe-task-definition \
--task-definition ${{ needs.setup_env.outputs.AWS_APPENV }} \
--query taskDefinition | \
jq 'del(.taskDefinitionArn,.revision,.status,.registeredBy,.registeredAt,.compatibilities,.requiresAttributes)' > task-def.json
- name: Interpolate new Docker Image into Task Definition
id: task-definition
uses: aws-actions/amazon-ecs-render-task-definition@v1.7.2
with:
task-definition: task-def.json
container-name: ${{ needs.setup_env.outputs.AWS_APPENV }}
image: ${{ steps.login-ecr.outputs.registry }}/${{ needs.setup_env.outputs.AWS_APPENV }}:${{ needs.setup_env.outputs.IMAGE_TAG }}
- name: Deploy Amazon ECS
uses: aws-actions/amazon-ecs-deploy-task-definition@v2.3.2
with:
task-definition: ${{ steps.task-definition.outputs.task-definition }}
service: ${{ needs.setup_env.outputs.AWS_APPENV }}
cluster: ${{ env.AWS_SHARED_CLUSTER }}
wait-for-service-stability: true
force-new-deployment: true
wait-for-minutes: 5 minutes
Loading
Loading