-
Notifications
You must be signed in to change notification settings - Fork 83
46 lines (44 loc) · 1.77 KB
/
build-publish-release-tag.yaml
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
name: Build Release Image
on:
#防止fork乱用action设置只能手动触发构建
workflow_dispatch:
## 发布release的时候会自动构建
release:
types: [published]
jobs:
publish-release-docker-image:
runs-on: ubuntu-latest
name: Build release image
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: |
cd web
npm install
- name: Build web
run: |
cd web
npm run build
- name: judge has env GITHUB_REF # 如果没有GITHUB_REF环境变量,则把github.ref变量赋值给GITHUB_REF
run: |
if [ -z "$GITHUB_REF" ]; then
export GITHUB_REF=${{ github.ref }}
fi
- name: Check GITHUB_REF env
run: echo $GITHUB_REF
- name: Get version
id: get_version
if: (startsWith(env.GITHUB_REF, 'refs/tags/')||startsWith(github.ref, 'refs/tags/')) && startsWith(github.repository, 'RockChinQ/free-one-api')
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Build image # image name: rockchin/free-one-api:<VERSION>
run: docker build --network=host -t rockchin/free-one-api:${{ steps.get_version.outputs.VERSION }} .
- name: Login to Registry
run: docker login --username=${{ secrets.DOCKER_HUB_USERNAME }} --password ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Push release image
if: (startsWith(env.GITHUB_REF, 'refs/tags/')||startsWith(github.ref, 'refs/tags/')) && startsWith(github.repository, 'RockChinQ/free-one-api')
run: docker push rockchin/free-one-api:${{ steps.get_version.outputs.VERSION }}