mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
Docs: update workflow for building docs image (#968)
Signed-off-by: Carson Yang <yangchuansheng33@gmail.com>
This commit is contained in:
120
.github/workflows/docs-image.yml
vendored
120
.github/workflows/docs-image.yml
vendored
@@ -8,82 +8,67 @@ on:
|
|||||||
- 'main'
|
- 'main'
|
||||||
tags:
|
tags:
|
||||||
- 'v*.*.*'
|
- 'v*.*.*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-fastgpt-docs-images:
|
build-fastgpt-docs-images:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Get current date and time
|
||||||
|
id: datetime
|
||||||
|
run: echo "datetime=$(date +'%Y%m%d%H%M%S')" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
# list of Docker images to use as base name for tags
|
||||||
- name: Set up QEMU (optional)
|
images: |
|
||||||
uses: docker/setup-qemu-action@v2
|
${{ secrets.DOCKER_HUB_NAME }}/fastgpt-docs
|
||||||
|
ghcr.io/${{ github.repository_owner }}/fastgpt-docs
|
||||||
|
registry.cn-hangzhou.aliyuncs.com/${{ secrets.ALI_HUB_USERNAME }}/fastgpt-docs
|
||||||
|
tags: |
|
||||||
|
${{ steps.datetime.outputs.datetime }}
|
||||||
|
flavor: latest=false
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
driver-opts: network=host
|
username: ${{ secrets.DOCKER_HUB_NAME }}
|
||||||
- name: Cache Docker layers
|
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
- name: Login to ghcr.io
|
||||||
path: /tmp/.buildx-cache
|
uses: docker/login-action@v3
|
||||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-buildx-
|
|
||||||
- name: Login to GitHub Container Registry
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GH_PAT }}
|
password: ${{ secrets.GH_PAT }}
|
||||||
- name: Set DOCKER_REPO_TAGGED based on branch or tag
|
|
||||||
run: |
|
|
||||||
if [[ "${{ github.ref_name }}" == "main" ]]; then
|
|
||||||
echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt-docs:latest" >> $GITHUB_ENV
|
|
||||||
else
|
|
||||||
echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt-docs:${{ github.ref_name }}" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
- name: Build and publish image for main branch or tag push event
|
|
||||||
env:
|
|
||||||
DOCKER_REPO_TAGGED: ${{ env.DOCKER_REPO_TAGGED }}
|
|
||||||
run: |
|
|
||||||
docker buildx build \
|
|
||||||
--build-arg name=app \
|
|
||||||
--platform linux/amd64,linux/arm64 \
|
|
||||||
--label "org.opencontainers.image.source= https://github.com/ ${{ github.repository_owner }}/FastGPT" \
|
|
||||||
--label "org.opencontainers.image.description=fastgpt image" \
|
|
||||||
--label "org.opencontainers.image.licenses=Apache" \
|
|
||||||
--push \
|
|
||||||
--cache-from=type=local,src=/tmp/.buildx-cache \
|
|
||||||
--cache-to=type=local,dest=/tmp/.buildx-cache \
|
|
||||||
-t ${DOCKER_REPO_TAGGED} \
|
|
||||||
-f docSite/Dockerfile \
|
|
||||||
.
|
|
||||||
push-to-docker-hub:
|
|
||||||
needs: build-fastgpt-docs-images
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
if: github.repository == 'labring/FastGPT'
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_HUB_NAME }}
|
|
||||||
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
|
||||||
- name: Set DOCKER_REPO_TAGGED based on branch or tag
|
|
||||||
run: |
|
|
||||||
if [[ "${{ github.ref_name }}" == "main" ]]; then
|
|
||||||
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
|
|
||||||
else
|
|
||||||
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
- name: Pull image from GitHub Container Registry
|
|
||||||
run: docker pull ghcr.io/${{ github.repository_owner }}/fastgpt-docs:${{env.IMAGE_TAG}}
|
|
||||||
- name: Tag image with Docker Hub repository name and version tag
|
|
||||||
run: docker tag ghcr.io/${{ github.repository_owner }}/fastgpt-docs:${{env.IMAGE_TAG}} ${{ secrets.DOCKER_IMAGE_NAME }}:${{env.IMAGE_TAG}}
|
|
||||||
- name: Push image to Docker Hub
|
|
||||||
run: docker push ${{ secrets.DOCKER_IMAGE_NAME }}:${{env.IMAGE_TAG}}
|
|
||||||
|
|
||||||
|
- name: Login to Aliyun
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: registry.cn-hangzhou.aliyuncs.com
|
||||||
|
username: ${{ secrets.ALI_HUB_USERNAME }}
|
||||||
|
password: ${{ secrets.ALI_HUB_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push Docker images to ghcr.io and DockerHub
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./docSite/Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
outputs:
|
||||||
|
tags: ${{ steps.datetime.outputs.datetime }}
|
||||||
update-docs-image:
|
update-docs-image:
|
||||||
needs: build-fastgpt-docs-images
|
needs: build-fastgpt-docs-images
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
@@ -95,4 +80,9 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
|
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
|
||||||
with:
|
with:
|
||||||
args: rollout restart deployment fastgpt-docs
|
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 }}
|
||||||
|
- uses: actions-hub/kubectl@master
|
||||||
|
env:
|
||||||
|
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
|
||||||
|
with:
|
||||||
|
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
|
Reference in New Issue
Block a user