Skip to content

chore: modified deploy process #72

chore: modified deploy process

chore: modified deploy process #72

Workflow file for this run

name: Deploy
on:
push:
branches:
- build/test
workflow_dispatch:
inputs:
environment:
description: 'Environment'
required: true
default: 'test'
env:
NODE_VERSION: "18.16.0"
PNPM_VERSION: "8.5.0"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Node_modules cache
uses: actions/cache@v2
with:
path: node_modules
key: node-modules-${{ runner.os }}
- name: install dependencies
run: |
pnpm install
- name: generate env file (Test)
if: github.event.inputs.environment == 'test' || github.ref == 'refs/heads/build/test'
run: |
echo "NODE_ENV=production" > .env
echo "ENVIRONMENT=test" > .env
echo "NEXT_PUBLIC_API_KEY=${{ secrets.TEXT_NEXT_PUBLIC_API_KEY }}" >> .env
echo "NEXT_PUBLIC_GA_MEASUREMENT_ID=${{ secrets.TEXT_NEXT_PUBLIC_GA_MEASUREMENT_ID }}" >> .env
- name: generate env file (Prod)
if: github.event.inputs.environment == 'prod'
run: |
echo "NODE_ENV=production" > .env
echo "ENVIRONMENT=production" > .env
echo "NEXT_PUBLIC_API_KEY=${{ secrets.PROD_NEXT_PUBLIC_API_KEY }}" >> .env
echo "NEXT_PUBLIC_GA_MEASUREMENT_ID=${{ secrets.PROD_NEXT_PUBLIC_GA_MEASUREMENT_ID }}" >> .env
- name: build
run: |
pnpm run build
- name: Archive build output
run: |
tar -czf build-output.tar.gz .next .env public Dockerfile start.sh next.config.js env.js node_modules
- name: Deploy to EC2 (Test)
if: github.event.inputs.environment == 'test' || github.ref == 'refs/heads/build/test'
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.TEST_SSH_PRIVATE_KEY }}
ARGS: "-rlgoDzvc -i"
SOURCE: build-output.tar.gz deploy.sh
TARGET: /home/${{ secrets.TEST_SSH_USER }}/appflowy.io
REMOTE_HOST: ${{ secrets.TEST_SSH_HOST }}
REMOTE_USER: ${{ secrets.TEST_SSH_USER }}
SCRIPT_AFTER: |
cd appflowy.io
chmod +x deploy.sh
sh deploy.sh
- name: Deploy to EC2 (Prod)
if: github.event.inputs.environment == 'prod'
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.PROD_SSH_PRIVATE_KEY }}
ARGS: "-rlgoDzvc -i"
TARGET: /home/${{ secrets.PROD_SSH_USER }}/appflowy.io
SOURCE: build-output.tar.gz deploy.sh
REMOTE_HOST: ${{ secrets.PROD_SSH_HOST }}
REMOTE_USER: ${{ secrets.PROD_SSH_USER }}
SCRIPT_AFTER: |
cd appflowy.io
chmod +x deploy.sh
sh deploy.sh