8
8
- ' main'
9
9
tags :
10
10
- ' v*.*.*'
11
+
11
12
jobs :
12
13
build-fastgpt-docs-images :
13
- runs-on : ubuntu-20.04
14
+ runs-on : ubuntu-latest
14
15
steps :
15
16
- name : Checkout
16
- uses : actions/checkout@v3
17
+ uses : actions/checkout@v4
18
+
19
+ - name : Get current date and time
20
+ id : datetime
21
+ run : echo "datetime=$(date +'%Y%m%d%H%M%S')" >> "$GITHUB_OUTPUT"
22
+
23
+ - name : Docker meta
24
+ id : meta
25
+ uses : docker/metadata-action@v5
17
26
with :
18
- fetch-depth : 1
19
- - name : Set up QEMU (optional)
20
- uses : docker/setup-qemu-action@v2
27
+ # list of Docker images to use as base name for tags
28
+ images : |
29
+ ${{ secrets.DOCKER_HUB_NAME }}/fastgpt-docs
30
+ ghcr.io/${{ github.repository_owner }}/fastgpt-docs
31
+ registry.cn-hangzhou.aliyuncs.com/${{ secrets.ALI_HUB_USERNAME }}/fastgpt-docs
32
+ tags : |
33
+ ${{ steps.datetime.outputs.datetime }}
34
+ flavor : latest=false
35
+
36
+ - name : Set up QEMU
37
+ uses : docker/setup-qemu-action@v3
38
+
21
39
- name : Set up Docker Buildx
22
- uses : docker/setup-buildx-action@v2
23
- with :
24
- driver-opts : network=host
25
- - name : Cache Docker layers
26
- uses : actions/cache@v2
40
+ uses : docker/setup-buildx-action@v3
41
+
42
+ - name : Login to DockerHub
43
+ uses : docker/login-action@v3
27
44
with :
28
- path : /tmp/.buildx-cache
29
- key : ${{ runner.os }}-buildx-${{ github.sha }}
30
- restore-keys : |
31
- ${{ runner.os }}-buildx-
32
- - name : Login to GitHub Container Registry
33
- uses : docker/login-action@v2
45
+ username : ${{ secrets.DOCKER_HUB_NAME }}
46
+ password : ${{ secrets.DOCKER_HUB_PASSWORD }}
47
+
48
+ - name : Login to ghcr.io
49
+ uses : docker/login-action@v3
34
50
with :
35
51
registry : ghcr.io
36
52
username : ${{ github.repository_owner }}
37
53
password : ${{ secrets.GH_PAT }}
38
- - name : Set DOCKER_REPO_TAGGED based on branch or tag
39
- run : |
40
- if [[ "${{ github.ref_name }}" == "main" ]]; then
41
- echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt-docs:latest" >> $GITHUB_ENV
42
- else
43
- echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt-docs:${{ github.ref_name }}" >> $GITHUB_ENV
44
- fi
45
- - name : Build and publish image for main branch or tag push event
46
- env :
47
- DOCKER_REPO_TAGGED : ${{ env.DOCKER_REPO_TAGGED }}
48
- run : |
49
- docker buildx build \
50
- --build-arg name=app \
51
- --platform linux/amd64,linux/arm64 \
52
- --label "org.opencontainers.image.source= https://github.com/ ${{ github.repository_owner }}/FastGPT" \
53
- --label "org.opencontainers.image.description=fastgpt image" \
54
- --label "org.opencontainers.image.licenses=Apache" \
55
- --push \
56
- --cache-from=type=local,src=/tmp/.buildx-cache \
57
- --cache-to=type=local,dest=/tmp/.buildx-cache \
58
- -t ${DOCKER_REPO_TAGGED} \
59
- -f docSite/Dockerfile \
60
- .
61
- push-to-docker-hub :
62
- needs : build-fastgpt-docs-images
63
- runs-on : ubuntu-20.04
64
- if : github.repository == 'labring/FastGPT'
65
- steps :
66
- - name : Checkout code
67
- uses : actions/checkout@v3
68
- - name : Login to Docker Hub
69
- uses : docker/login-action@v2
54
+
55
+ - name : Login to Aliyun
56
+ uses : docker/login-action@v3
70
57
with :
71
- username : ${{ secrets.DOCKER_HUB_NAME }}
72
- password : ${{ secrets.DOCKER_HUB_PASSWORD }}
73
- - name : Set DOCKER_REPO_TAGGED based on branch or tag
74
- run : |
75
- if [[ "${{ github.ref_name }}" == "main" ]]; then
76
- echo "IMAGE_TAG=latest" >> $GITHUB_ENV
77
- else
78
- echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
79
- fi
80
- - name : Pull image from GitHub Container Registry
81
- run : docker pull ghcr.io/${{ github.repository_owner }}/fastgpt-docs:${{env.IMAGE_TAG}}
82
- - name : Tag image with Docker Hub repository name and version tag
83
- run : docker tag ghcr.io/${{ github.repository_owner }}/fastgpt-docs:${{env.IMAGE_TAG}} ${{ secrets.DOCKER_IMAGE_NAME }}:${{env.IMAGE_TAG}}
84
- - name : Push image to Docker Hub
85
- run : docker push ${{ secrets.DOCKER_IMAGE_NAME }}:${{env.IMAGE_TAG}}
58
+ registry : registry.cn-hangzhou.aliyuncs.com
59
+ username : ${{ secrets.ALI_HUB_USERNAME }}
60
+ password : ${{ secrets.ALI_HUB_PASSWORD }}
86
61
62
+ - name : Build and push Docker images to ghcr.io and DockerHub
63
+ uses : docker/build-push-action@v5
64
+ with :
65
+ context : .
66
+ file : ./docSite/Dockerfile
67
+ push : true
68
+ tags : ${{ steps.meta.outputs.tags }}
69
+ labels : ${{ steps.meta.outputs.labels }}
70
+ outputs :
71
+ tags : ${{ steps.datetime.outputs.datetime }}
87
72
update-docs-image :
88
73
needs : build-fastgpt-docs-images
89
74
runs-on : ubuntu-20.04
95
80
env :
96
81
KUBE_CONFIG : ${{ secrets.KUBE_CONFIG }}
97
82
with :
98
- args : rollout restart deployment fastgpt-docs
83
+ args : set image deployment/fastgpt-docs fastgpt-docs=registry.cn-hangzhou.aliyuncs.com/${{ secrets.ALI_HUB_USERNAME }}/fastgpt-docs:${{ needs.build-fastgpt-docs-images.outputs.tags }}
84
+ - uses : actions-hub/kubectl@master
85
+ env :
86
+ KUBE_CONFIG : ${{ secrets.KUBE_CONFIG }}
87
+ with :
88
+ args : annotate deployment/fastgpt-docs originImageName="registry.cn-hangzhou.aliyuncs.com/${{ secrets.ALI_HUB_USERNAME }}/fastgpt-docs:${{ needs.build-fastgpt-docs-images.outputs.tags }}" --overwrite
0 commit comments