Skip to content

docs: Development Specifications (#83) #21

docs: Development Specifications (#83)

docs: Development Specifications (#83) #21

Workflow file for this run

name: Build image and push to registry
on:
workflow_dispatch:
push:
tags: ['v*']
permissions:
contents: read
packages: write
jobs:
build-image:
strategy:
matrix:
archs:
- arch: amd64
- arch: arm64
runs-on: ubuntu-24.04-arm
runs-on: ${{ matrix.archs.runs-on || 'ubuntu-24.04' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push for ${{ matrix.archs.arch }}
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/${{ matrix.archs.arch }}
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/fastgpt-plugin:${{ github.sha }}-${{ matrix.archs.arch }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.description=https://github.com/${{ github.repository }} image
cache-from: type=gha,scope=${{ matrix.archs.arch }}
cache-to: type=gha,mode=max,scope=${{ matrix.archs.arch }}
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.archs.arch }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge-image:
runs-on: ubuntu-latest
needs:
- build-image
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_NAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Login to Ali Hub
uses: docker/login-action@v3
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ALI_HUB_USERNAME }}
password: ${{ secrets.ALI_HUB_PASSWORD }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
# Define all tags for different registries
GITHUB_TAG="ghcr.io/${{ github.repository_owner }}/fastgpt-plugin:${{ github.ref_name }}"
GITHUB_LATEST="ghcr.io/${{ github.repository_owner }}/fastgpt-plugin:latest"
GITHUB_SHA="ghcr.io/${{ github.repository_owner }}/fastgpt-plugin:${{ github.sha }}"
ALI_TAG="${{ secrets.ALI_IMAGE_NAME }}/fastgpt-plugin:${{ github.ref_name }}"
ALI_LATEST="${{ secrets.ALI_IMAGE_NAME }}/fastgpt-plugin:latest"
ALI_SHA="${{ secrets.ALI_IMAGE_NAME }}/fastgpt-plugin:${{ github.sha }}"
DOCKER_TAG="${{ secrets.DOCKER_IMAGE_NAME }}/fastgpt-plugin:${{ github.ref_name }}"
DOCKER_LATEST="${{ secrets.DOCKER_IMAGE_NAME }}/fastgpt-plugin:latest"
DOCKER_SHA="${{ secrets.DOCKER_IMAGE_NAME }}/fastgpt-plugin:${{ github.sha }}"
# Create array of all tags
TAGS="$GITHUB_TAG $GITHUB_LATEST $GITHUB_SHA $ALI_TAG $ALI_LATEST $ALI_SHA $DOCKER_TAG $DOCKER_LATEST $DOCKER_SHA"
# Create manifest list for each tag
for TAG in $TAGS; do
echo "Creating manifest list for: $TAG"
docker buildx imagetools create -t $TAG \
$(printf 'ghcr.io/${{ github.repository_owner }}/fastgpt-plugin@sha256:%s ' *)
sleep 2
done