mirror of
https://github.com/hi2shark/nazhua.git
synced 2026-01-15 08:40:43 +08:00
✨ 工作流
This commit is contained in:
parent
e2e186329e
commit
7b9d078c5e
43
.github/workflows/docker-build.yml
vendored
Normal file
43
.github/workflows/docker-build.yml
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main # 监听 main 分支的 push 操作
|
||||
workflow_dispatch: # 手动触发
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Get version from package.json
|
||||
id: get_version
|
||||
run: echo "VERSION=$(node -p \"require('./package.json').version\")" >> $GITHUB_ENV
|
||||
|
||||
- name: Build project
|
||||
run: npm run build
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
docker build -t ghcr.io/${{ github.repository }}/nazhua:${{ env.VERSION }} .
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
|
||||
- name: Push Docker image
|
||||
run: |
|
||||
docker push ghcr.io/${{ github.repository }}/nazhua:${{ env.VERSION }}
|
||||
docker tag ghcr.io/${{ github.repository }}/nazhua:${{ env.VERSION }} ghcr.io/${{ github.repository }}/nazhua:latest
|
||||
docker push ghcr.io/${{ github.repository }}/nazhua:latest
|
||||
@ -2,3 +2,6 @@ FROM nginx:1.27.3
|
||||
|
||||
COPY ./dist /home/wwwroot/html
|
||||
COPY ./nginx-default.conf.template /etc/nginx/templates/default.conf.template
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 80
|
||||
|
||||
Loading…
Reference in New Issue
Block a user