Skip to content

Commit

Permalink
update github action
Browse files Browse the repository at this point in the history
  • Loading branch information
vahid1402 committed Nov 3, 2024
1 parent 99ded78 commit 5f0ccaf
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.dockerignore
node_modules
storybook-static
.npmrc
dist
.idea
28 changes: 26 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ on:
branches: [main]

jobs:
build:
test:
runs-on: ubuntu-latest

name: Run build on push main
name: Run test on push main
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
Expand All @@ -27,3 +27,27 @@ jobs:
"npx http-server storybook-static --port 6006 --silent" \
"npx wait-on tcp:6006 && pnpm cypress:run"
- run: pnpm run build

deploy:
runs-on: ubuntu-latest
needs: test

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DEV_SSH_PRIVATE_KEY }}

- name: Deploy to Server
env:
DEPLOY_USER: ${{ secrets.DEV_SSH_USER }}
DEPLOY_HOST: ${{ secrets.DEV_SSH_HOST }}
DEPLOY_PATH: ${{ secrets.DEV_SSH_DEPLOY_PATH }}
run: |
echo $DEPLOY_PATH
ssh-keyscan $DEPLOY_HOST >> ~/.ssh/known_hosts
rsync -avz -e "ssh -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o BatchMode=yes" --rsync-path="TERM=xterm rsync" $GITHUB_WORKSPACE/ $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH
ssh -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o BatchMode=yes $DEPLOY_USER@$DEPLOY_HOST "cd $DEPLOY_PATH && (docker stop storybook-build || true) && (docker rm storybook-build || true) && docker build -t storybook-build . && docker run -d -p 6006:6006 --name storybook-build storybook-build"
5 changes: 4 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ tsconfig.node.json
tsconfig.json
tsconfig.app.tsbuildinfo
tsconfig.node.tsbuildinfo
vite.config.ts
vite.config.ts
Dockerfile
.dockerignore
storybook-static
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:lts-alpine

WORKDIR /app

RUN npm install -g pnpm
RUN npm install -g serve

COPY package.json pnpm-lock.yaml ./

RUN pnpm install

COPY . .

RUN pnpm run build-storybook

EXPOSE 6006

CMD ["npx", "serve", "-l", "6006", "storybook-static"]

0 comments on commit 5f0ccaf

Please sign in to comment.