-
Notifications
You must be signed in to change notification settings - Fork 16
101 lines (83 loc) · 2.6 KB
/
pages-build-deployment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: pages-build-deployment
on:
push:
branches: [ master ]
tags:
- v*
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
# Image name
IMAGE_NAME: bfbanv2-frontend
jobs:
build:
runs-on: ubuntu-latest
# 该项目请使用指定的node
# Use the specified node for this project
strategy:
matrix:
node-version: [ 16.0.0 ]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
working-directory: ./front
- run: npm run build:production --if-present
working-directory: ./front
- name: Commit changes
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: './front/dist'
commit-message: 'build front'
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Registry
uses: docker/login-action@v1
with:
# registry: docker.pkg.github.com
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: ${{ runner.os }}-buildx-
- uses: docker/build-push-action@v5
with:
context: ./front
file: ./front/nginx.Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/bfban/bfban-website/${{ env.IMAGE_NAME }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: gh-pages
- name: Deploy to netlify
uses: netlify/actions/cli@master
with:
args: deploy --dir=public --prod
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}