TTRPG Scheduler Deploy sjkneisler #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
name: TTRPG Scheduler Deploy | |
run-name: TTRPG Scheduler Deploy ${{ github.actor }} | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
deploybackend: | |
name: Deploy Backend | |
runs-on: ubuntu-latest | |
environment: sandbox | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Login to 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 }} | |
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }} | |
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 "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT | |
- name: Download task definition | |
# TODO: Update this command to programmatically pull the task definition family | |
run: | | |
aws ecs describe-task-definition --task-definition ttrpg-scheduler-first-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: ttrpg-scheduler-first-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: ${{ vars.ECS_SERVICE }} | |
cluster: ${{ vars.ECS_CLUSTER }} | |
wait-for-service-stability: true | |
deployfrontend: | |
name: Deploy Frontend | |
runs-on: ubuntu-latest | |
environment: sandbox | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Install dependencies | |
run: yarn install | |
- name: Generate Prisma files | |
run: yarn db:generate | |
- name: Build frontend | |
env: | |
REACT_APP_SERVER_URL: ${{ vars.REACT_APP_SERVER_URL }} | |
CI: false # TODO: Remove this - this was added to not treat lint warnings as errors | |
run: yarn build:frontend | |
- name: Deploy frontend S3 bucket | |
run: aws s3 sync ./build/ "s3://${{ vars.FRONTEND_S3_BUCKET }}" --delete |