-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
616964d
commit 3959d10
Showing
3 changed files
with
59 additions
and
14 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 |
---|---|---|
|
@@ -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 |
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,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 |
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,9 @@ | ||
server { | ||
listen 80; | ||
server_name frontend; | ||
|
||
location / { | ||
root /usr/share/nginx/html; | ||
try_files $uri $uri/ /index.html; | ||
} | ||
} |