Skip to content

deploy

deploy #7

Workflow file for this run

name: deploy
on:
push:
branches:
- develop
workflow_dispatch:
jobs:
deploy_development:
runs-on: ubuntu-22.04
timeout-minutes: 10
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Install Dependencies
run: npm ci
- name: Create .env File
env:
PREFIX: 'NEXT_PUBLIC_'
SECRETS: ${{ toJson(secrets) }}
run: |
touch .env && \
jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' <<< "$SECRETS" | grep $PREFIX > .env
- name: Build
run: npm run build
- name: Collect Code
run: |
mkdir -p build/.next && \
cp -r .next/standalone/. build/. && \
cp -r public build && \
cp -r .next/static build/.next
- name: Compress
run: |
mkdir tars && \
tar -cvzf - build | \
split -b 100M - \
tars/${GITHUB_SHA::8}.tar.gz.
- name: Upload to S3
run: |
aws s3 sync \
--region ${{ secrets.AWS_REGION }} \
tars ${{secrets.S3_DEV_FRONT_LOCATION}}
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST_DEV }}
username: ${{ secrets.EC2_USER_DEV }}
port: ${{ secrets.EC2_PORT_DEV }}
key: ${{ secrets.EC2_KEY_DEV }}
envs: GITHUB_SHA
script: |
cd ~/soundflyer-infra/deploy
chmod +x ./deploy_front.sh
sudo -E ./deploy_front.sh ${GITHUB_SHA::8} dev