forked from PillarsZhang/captcha-cv-ocr
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (116 loc) · 3.98 KB
/
release.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
name: Publish Package to npmjs
on:
push:
tags:
- "v*.*.*"
# release:
# types: [created]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ${{ secrets.REGISTRY }}
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
npm-publish:
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.com
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --no-frozen-lockfile --ignore-scripts
# - name: Build and npm-publish
# run: npm run release
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
# run: npm run publish:github # --registry=https://npm.pkg.github.com
# env:
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
# - name: GitHub Pages action
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./docs
- name: Github Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: false
prerelease: false
# tag_name: ${{ github.ref }}
# name: Release ${{ github.ref }}
# body: TODO New Release.
# files: |
# ${{ secrets.ReleaseZipName }}.zip
# LICENSE
docker-deploy:
runs-on: ubuntu-latest
steps:
# 提供 docker 元数据,构建 docker images tag 时使用
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
# tag event
type=ref,enable=true,priority=600,prefix=,suffix=,event=tag
# 构建镜像 使用 docker/Build-And-push@v5 插件有问题
- uses: actions/checkout@v2
- name: Build Docker Image
run: |
docker build -t ${{ env.REGISTRY }}/${{ steps.meta.outputs.tags }} -f ./docker/nginx/Dockerfile .
- name: Push Docker Image
run: |
docker login --username=${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }} ${{ env.REGISTRY }}
docker push ${{ env.REGISTRY }}/${{ steps.meta.outputs.tags }}
# 运行 docker 服务
# 另外一种选择是通过 scp 将文件传到指定服务器,完成 docker-compose 启动
# - name: Deploy Docker App
# uses: appleboy/ssh-action@master
# env:
# TZ: Asia/Shanghai
# with:
# host: ${{ secrets.HOST }}
# username: ${{ secrets.HOST_USERNAME }}
# key: ${{ secrets.HOST_SSHKEY }}
# port: ${{ secrets.PORT }}
# script: |
# # 获取 docker-compose 文件
# wget https://raw.githubusercontent.com/${{ env.IMAGE_NAME }}/master/docker/docker-compose.yml
# ls
# cat docker-compose.yml
# docker-compose down -v
# docker-compose up -d