Skip to content

Commit

Permalink
Update pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
wen-templari committed Oct 22, 2023
1 parent 616964d commit 3959d10
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 14 deletions.
51 changes: 37 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,48 @@ on:
push:
branches:
- v2

env:
REGISTRY: ghcr.io
IMAGE_NAME: sunday
IMAGE_NAME_FULL: ghcr.io/nbtca/sunday

jobs:
build:
runs-on: ubuntu-latest
steps:
# 切换分支
- name: Checkout
uses: actions/checkout@master
- uses: actions/setup-node@v2

- name: Login DockerHub
uses: docker/login-action@v2
with:
node-version: "16"
- run: npm install
- run: npm run build
# Deploy
- name: ssh deploy
uses: easingthemes/[email protected]
env:
SSH_PRIVATE_KEY: ${{ secrets.ACCESS_TOKEN }}
ARGS: "-avz --delete"
SOURCE: "dist/"
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: "/home/nbtca/weekend/web/v2"
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push to DockerHub
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
no-cache: true
# target: deploy
push: true
platforms: linux/amd64
tags: |
${{ env.IMAGE_NAME_FULL }}:latest
- name: ssh pipelines
uses: cross-the-world/ssh-pipeline@master
with:
host: ${{ secrets.REMOTE_HOST }}
user: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.ACCESS_TOKEN }}
connect_timeout: 10s
script: |
cd /home/nbtca/weekend/sunday
docker-compose stop && docker-compose rm -f
docker rmi ${{ env.IMAGE_NAME_FULL }}:latest
docker-compose up -d
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node as build

COPY . /app
WORKDIR /app

RUN npm install &&\
npm run build


FROM nginx:alpine as deploy

COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
9 changes: 9 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {
listen 80;
server_name frontend;

location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
}
}

0 comments on commit 3959d10

Please sign in to comment.