dify/.github/workflows/build-web-image.yml

63 lines
1.8 KiB
YAML
Raw Normal View History

2023-05-15 08:51:32 +08:00
name: Build and Push WEB Image
on:
push:
branches:
- 'main'
- 'deploy/dev'
2023-05-25 20:17:17 +08:00
release:
types: [published]
2023-05-15 08:51:32 +08:00
jobs:
build-and-push:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
2023-05-25 20:17:17 +08:00
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
2023-05-15 08:51:32 +08:00
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2023-05-25 20:17:17 +08:00
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: langgenius/dify-web
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=sha,enable=true,priority=100,prefix=,suffix=,format=long
2023-05-25 20:17:17 +08:00
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: "{{defaultContext}}:web"
platforms: ${{ github.ref == 'refs/heads/deploy/dev' && 'linux/amd64' || 'linux/amd64,linux/arm64' }}
2023-05-25 20:17:17 +08:00
build-args: |
COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
2023-05-15 08:51:32 +08:00
- name: Deploy to server
if: github.ref == 'refs/heads/deploy/dev'
uses: appleboy/ssh-action@v0.1.8
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
${{ secrets.SSH_SCRIPT }}