Skip to content

fix: github workflows #8

fix: github workflows

fix: github workflows #8

Workflow file for this run

name: Build and Push Daemon
on:
push:
branches:
- "main"
- "deploy/dev"
release:
types: [published]
concurrency:
group: build-push-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DIFY_DAEMON_IMAGE_NAME: ${{ vars.DIFY_DAEMON_IMAGE_NAME || 'langgenius/dify-plugin-daemon' }}
jobs:
build:
runs-on: ${{ matrix.platform == 'linux/arm64' && 'arm64_runner' || 'ubuntu-latest' }}
if: github.repository == 'langgenius/dify-plugin-daemon'
strategy:
matrix:
include:
- service_name: "build-serverless-daemon-amd64"
image_name_env: "DIFY_DAEMON_IMAGE_NAME"
platform: linux/amd64
dockerfile: "docker/serverless/Dockerfile"
scope: serverless
- service_name: "build-serverless-daemon-arm64"
image_name_env: "DIFY_DAEMON_IMAGE_NAME"
platform: linux/arm64
dockerfile: "docker/serverless/Dockerfile"
scope: serverless
- service_name: "build-local-daemon-amd64"
image_name_env: "DIFY_DAEMON_IMAGE_NAME"
platform: linux/amd64
dockerfile: "docker/local/Dockerfile"
scope: local
- service_name: "build-local-daemon-arm64"
image_name_env: "DIFY_DAEMON_IMAGE_NAME"
platform: linux/arm64
dockerfile: "docker/local/Dockerfile"
scope: local
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USER }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: ${{ matrix.platform }}
push: true
tags: |
${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-latest
${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-${{ github.sha }}
${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-${{ env.BRANCH_NAME }}
cache-from: type=gha,scope=${{ matrix.service_name }}
cache-to: type=gha,mode=max,scope=${{ matrix.service_name }}
create-manifest:
needs: build
runs-on: ubuntu-latest
if: github.repository == 'langgenius/dify-plugin-daemon'
strategy:
matrix:
scope: [serverless, local]
steps:
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USER }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Create and push manifest
run: |
docker manifest create ${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-latest \
${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-latest-linux-amd64 \
${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-latest-linux-arm64
docker manifest push ${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-latest
docker manifest create ${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-${{ github.sha }} \
${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-${{ github.sha }}-linux-amd64 \
${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-${{ github.sha }}-linux-arm64
docker manifest push ${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-${{ github.sha }}
docker manifest create ${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-${{ env.BRANCH_NAME }} \
${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-${{ env.BRANCH_NAME }}-linux-amd64 \
${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-${{ env.BRANCH_NAME }}-linux-arm64
docker manifest push ${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-${{ env.BRANCH_NAME }}
- name: Inspect images
run: |
docker buildx imagetools inspect ${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-latest
docker buildx imagetools inspect ${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-${{ github.sha }}
docker buildx imagetools inspect ${{ env.DIFY_DAEMON_IMAGE_NAME }}:${{ matrix.scope }}-${{ env.BRANCH_NAME }}