Skip to content

Commit 80bdbf6

Browse files
Docs: update workflow for building docs image (FlowiseAI#968)
Signed-off-by: Carson Yang <yangchuansheng33@gmail.com>
1 parent 9f0b1d6 commit 80bdbf6

File tree

1 file changed

+54
-64
lines changed

1 file changed

+54
-64
lines changed

.github/workflows/docs-image.yml

+54-64
Original file line numberDiff line numberDiff line change
@@ -8,82 +8,67 @@ on:
88
- 'main'
99
tags:
1010
- 'v*.*.*'
11+
1112
jobs:
1213
build-fastgpt-docs-images:
13-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-latest
1415
steps:
1516
- 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
1726
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+
2139
- 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
2744
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
3450
with:
3551
registry: ghcr.io
3652
username: ${{ github.repository_owner }}
3753
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
7057
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 }}
8661

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 }}
8772
update-docs-image:
8873
needs: build-fastgpt-docs-images
8974
runs-on: ubuntu-20.04
@@ -95,4 +80,9 @@ jobs:
9580
env:
9681
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
9782
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

Comments
 (0)