fix: deploy

This commit is contained in:
Kilu 2024-06-30 15:31:16 +08:00
parent 28e3025c83
commit 655b0735bb
4 changed files with 109 additions and 3 deletions

View File

@ -3,7 +3,7 @@ name: Deploy Web (Test)
on:
push:
branches:
- build/test
- build/old-test
env:
NODE_VERSION: "18.16.0"
PNPM_VERSION: "8.5.0"
@ -72,4 +72,4 @@ jobs:
docker system prune -f
docker build -t appflowy-web-app .
docker rm -f appflowy-web-app || true
docker run -d -p 3000:80 --env-file .env --name appflowy-web-app appflowy-web-app
docker run -d -p 30012:80 --env-file .env --name appflowy-web-app appflowy-web-app

93
.github/workflows/deploy_web.yaml vendored Normal file
View File

@ -0,0 +1,93 @@
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"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
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: frontend/appflowy_web_app/node_modules
key: node-modules-${{ runner.os }}
- name: install frontend dependencies
working-directory: frontend/appflowy_web_app
run: |
pnpm install
- name: generate env file (Test)
if: github.event.inputs.environment == 'test' || github.ref == 'refs/heads/build/test'
working-directory: frontend/appflowy_web_app
run: |
cp test.env .env
- name: generate env file (Prod)
if: github.event.inputs.environment == 'prod'
working-directory: frontend/appflowy_web_app
run: |
cp beta.env .env
- name: test and lint
working-directory: frontend/appflowy_web_app
run: |
pnpm run lint
- name: build
working-directory: frontend/appflowy_web_app
run: |
pnpm run build
- name: Archive build output
working-directory: frontend/appflowy_web_app
run: |
tar -czf build-output.tar.gz frontend/appflowy_web_app/dist frontend/appflowy_web_app/server.cjs frontend/appflowy_web_app/start.sh frontend/appflowy_web_app/Dockerfile frontend/appflowy_web_app/nginx.conf frontend/appflowy_web_app/.env
- 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.WEB_TEST_SSH_PRIVATE_KEY }}
ARGS: "-rlgoDzvc -i"
SOURCE: build-output.tar.gz deploy.sh
TARGET: /home/${{ secrets.WEB_TEST_REMOTE_USER }}/appflowy-web-app
REMOTE_HOST: ${{ secrets.WEB_TEST_REMOTE_HOST }}
REMOTE_USER: ${{ secrets.WEB_TEST_REMOTE_USER }}
SCRIPT_AFTER: |
cd appflowy-web-app
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.WEB_PROD_SSH_PRIVATE_KEY }}
ARGS: "-rlgoDzvc -i"
TARGET: /home/${{ secrets.WEB_PROD_REMOTE_USER }}/appflowy-web-app
SOURCE: build-output.tar.gz deploy.sh
REMOTE_HOST: ${{ secrets.WEB_PROD_REMOTE_HOST }}
REMOTE_USER: ${{ secrets.WEB_PROD_REMOTE_USER }}
SCRIPT_AFTER: |
cd appflowy-web-app
chmod +x deploy.sh
sh deploy.sh

View File

@ -0,0 +1,13 @@
rm -rf dist
tar -xzf build-output.tar.gz
rm -rf build-output.tar.gz
docker system prune -f
docker build -t appflowy-web-app .
docker rm -f appflowy-web-app || true
docker run -d --env-file .env -p 30012:80 --restart always --name appflowy-web-app appflowy-web-app

View File

@ -80,10 +80,10 @@ export function PublishView({ namespace, publishName }: PublishViewProps) {
}}
openDrawer={open}
/>
{open && <OutlineDrawer width={drawerWidth} open={open} onClose={() => setOpen(false)} />}
<CollabView doc={doc} />
</AFScroller>
{open && <OutlineDrawer width={drawerWidth} open={open} onClose={() => setOpen(false)} />}
</div>
</PublishProvider>
);