-
Notifications
You must be signed in to change notification settings - Fork 760
56 lines (54 loc) · 1.91 KB
/
osharp_docs.yml
File metadata and controls
56 lines (54 loc) · 1.91 KB
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
name: Publish Osharp Docs
on:
workflow_dispatch:
push:
branches: [master]
paths:
- "docs/**"
- ".github/workflows/osharp_docs.yml"
env:
REGISTRY: docker.io
IMAGE_NAME: gmf520/osharp.docs
jobs:
publish_osharp_docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
# 由于docs.osharp的发布可能会比较频繁,使用当前时间的"月日时分"作为子版本token
- name: Get Time Version Token
id: current_time
run: echo "::set-output name=time::$(date +'%m%d%H%M')"
# 取最后一个git tag 并拆分出主版本号作为主版本
- name: Get Last Tag
id: last_tag
run: echo "::set-output name=tag::$(git describe --tags --abbrev=0)"
- name: Split Tag
id: split_tag
uses: jungwinter/split@v2
with:
msg: ${{ steps.last_tag.outputs.tag }}
separator: "-"
- name: Build Docker Image
env:
VERSION: "${{ steps.split_tag.outputs._0 }}.${{ steps.current_time.outputs.time }}"
run: |
cd ./docs
echo "Build docker image, tag: ${{env.IMAGE_NAME}}:${{env.VERSION}}"
docker build -t ${{env.IMAGE_NAME}}:${{env.VERSION}} .
docker tag ${{env.IMAGE_NAME}}:${{env.VERSION}} ${{env.IMAGE_NAME}}:latest
- name: Docker Login
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_LOGIN_TOKEN }}
- name: Push Docker Image
env:
VERSION: "${{ steps.split_tag.outputs._0 }}.${{ steps.current_time.outputs.time }}"
run: |
echo "Push docker image, tag: ${{env.IMAGE_NAME}}:${{env.VERSION}}"
docker push ${{env.IMAGE_NAME}}:${{env.VERSION}}
docker push ${{env.IMAGE_NAME}}:latest