58 lines
1.8 KiB
YAML
58 lines
1.8 KiB
YAML
name: Deploy to Production
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Configure AWS credentials
|
|
uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83
|
|
with:
|
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
aws-region: ${{ secrets.AWS_REGION }}
|
|
|
|
- name: Log into Amazon ECR
|
|
id: login-ecr
|
|
uses: aws-actions/amazon-ecr-login@v2
|
|
|
|
- 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: |
|
|
docker build \
|
|
--build-arg DB_URL=${{ secrets.DB_URL }} \
|
|
-t $ECR_REGISTRY/stan/personal-website:$IMAGE_TAG \
|
|
packages/web
|
|
docker push $ECR_REGISTRY/stan/personal-website:$IMAGE_TAG
|
|
echo "image=$ECR_REGISTRY/stan/personal-website:$IMAGE_TAG" >> $GITHUB_OUTPUT
|
|
|
|
- name: Render ECS Task Definition
|
|
id: task-def
|
|
uses: aws-actions/amazon-ecs-render-task-definition@c804dfbdd57f713b6c079302a4c01db7017a36fc
|
|
with:
|
|
task-definition: .github/workflows/taskdef.json
|
|
container-name: web
|
|
image: ${{ steps.build-image.outputs.image }}
|
|
|
|
- name: Deploy to Amazon ECS
|
|
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
|
|
with:
|
|
task-definition: ${{ steps.task-def.outputs.task-definition }}
|
|
service: main-service
|
|
cluster: PersonalWebsiteCluster
|
|
wait-for-service-stability: true
|