Skip to content

deploy-aws

deploy-aws #106

Workflow file for this run

name: deploy-aws
on:
workflow_dispatch:
env:
# server
IMAGE: reearth/reearth-cms:nightly
IMAGE_AWS: reearth-cms-test-server:latest
# worker
WORKER_IMAGE: reearth/reearth-cms-worker:nightly
WORKER_IMAGE_AWS: reearth-cms-test-worker:latest
jobs:
deploy_web:
name: Deploy web to AWS
runs-on: ubuntu-latest
defaults:
run:
working-directory: web
steps:
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: actions/checkout@v4
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install
run: yarn install
- name: Lint
run: yarn run lint
- name: Test
run: yarn run coverage
- name: Send coverage report
uses: codecov/codecov-action@v3
with:
flags: web
- name: Check translations
run: yarn i18n --fail-on-update
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Install Amplify CLI
run: yarn global add @aws-amplify/cli
- name: Pull Amplify project
run: amplify pull --appId ${{ secrets.AWS_AMPLIFY_APP_ID }} --envName test --yes
- name: Build and Deploy to Amplify
run: amplify publish --appId ${{ secrets.AWS_AMPLIFY_APP_ID }} --envName test --yes
deploy_server:
name: Deploy server to AWS
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Log in to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: docker pull, push to ECR
run: |
docker pull $IMAGE
docker tag $IMAGE ${{ steps.login-ecr.outputs.registry }}/$IMAGE_AWS
docker push ${{ steps.login-ecr.outputs.registry }}/$IMAGE_AWS
deploy_worker:
name: Deploy worker to AWS
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Log in to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: docker pull, push to ECR
run: |
docker pull $WORKER_IMAGE
docker tag $WORKER_IMAGE ${{ steps.login-ecr.outputs.registry }}/$WORKER_IMAGE_AWS
docker push ${{ steps.login-ecr.outputs.registry }}/$WORKER_IMAGE_AWS