forked from AppFlowy-IO/AppFlowy-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
585 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# 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 [email protected] | ||
|
||
COPY . . | ||
|
||
# Expose the port the app runs on | ||
COPY . /app | ||
|
||
RUN chmod +x /app/start.sh | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["/app/start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
rm -rf .next .env public start.sh Dockerfile next.config.js env.js node_modules | ||
|
||
tar -xzf build-output.tar.gz | ||
|
||
rm build-output.tar.gz | ||
|
||
docker system prune -f | ||
|
||
docker build -t official-website-app . | ||
|
||
docker rm -f official-website-app || true | ||
|
||
docker run -d --env-file .env -p 3001:3000 --name official-website-app official-website-app |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.