diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f8dd788 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,84 @@ +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 "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 "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 nginx.conf 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 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6f3072d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# Use the official Node.js image as a base image +FROM node:18 +# Create and change to the app directory +WORKDIR /app + +RUN npm install -g pnpm@8.5.0 + +RUN apt-get update && \ + apt-get install -y nginx + +COPY . . + +RUN addgroup --system nginx && \ + adduser --system --no-create-home --disabled-login --ingroup nginx nginx + +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +COPY nginx.conf /etc/nginx/nginx.conf +COPY .next/ /usr/share/nginx/html/.next/ +COPY public/ /usr/share/nginx/html/public/ + +# Expose the port the app runs on +COPY start.sh /app/start.sh +COPY next.config.js /app/next.config.js +COPY .env /app/.env +COPY env.js /app/env.js +COPY .next /app/.next +COPY public /app/public + +RUN chmod +x /app/start.sh + +EXPOSE 80 + +CMD ["/app/start.sh"] \ No newline at end of file diff --git a/app/invitation/expired/page.tsx b/app/invitation/expired/page.tsx index 71af1e6..d2a86a1 100644 --- a/app/invitation/expired/page.tsx +++ b/app/invitation/expired/page.tsx @@ -4,16 +4,13 @@ import ExpireDescription from '@/components/invitation/expired-description'; import InviteOwner from '@/components/invitation/invite-owner'; import InviteWorkspace from '@/components/invitation/invite-workspace'; import '@/styles/invitation.scss'; -import { Poppins } from 'next/font/google'; import Image from 'next/image'; import Link from 'next/link'; import NextTopLoader from 'nextjs-toploader'; -const poppins = Poppins({ subsets: ['latin'], weight: ['400', '500', '600', '700'] }); - function Page() { return ( -