build-web-image.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. name: Build and Push WEB Image
  2. on:
  3. push:
  4. branches:
  5. - 'main'
  6. - 'deploy/dev'
  7. release:
  8. types: [published]
  9. jobs:
  10. build-and-push:
  11. runs-on: ubuntu-latest
  12. if: github.event.pull_request.draft == false
  13. steps:
  14. - name: Set up QEMU
  15. uses: docker/setup-qemu-action@v2
  16. - name: Set up Docker Buildx
  17. uses: docker/setup-buildx-action@v2
  18. - name: Login to Docker Hub
  19. uses: docker/login-action@v2
  20. with:
  21. username: ${{ secrets.DOCKERHUB_USER }}
  22. password: ${{ secrets.DOCKERHUB_TOKEN }}
  23. - name: Extract metadata (tags, labels) for Docker
  24. id: meta
  25. uses: docker/metadata-action@v4
  26. with:
  27. images: langgenius/dify-web
  28. tags: |
  29. type=raw,value=latest,enable={{is_default_branch}}
  30. type=ref,event=branch
  31. type=sha,enable=true,priority=100,prefix=,suffix=,format=long
  32. type=semver,pattern={{major}}.{{minor}}.{{patch}}
  33. type=semver,pattern={{major}}.{{minor}}
  34. type=semver,pattern={{major}}
  35. - name: Build and push
  36. uses: docker/build-push-action@v4
  37. with:
  38. context: "{{defaultContext}}:web"
  39. platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
  40. build-args: |
  41. COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
  42. push: true
  43. tags: ${{ steps.meta.outputs.tags }}
  44. labels: ${{ steps.meta.outputs.labels }}
  45. cache-from: type=gha
  46. cache-to: type=gha,mode=max
  47. - name: Deploy to server
  48. if: github.ref == 'refs/heads/deploy/dev'
  49. uses: appleboy/ssh-action@v0.1.8
  50. with:
  51. host: ${{ secrets.SSH_HOST }}
  52. username: ${{ secrets.SSH_USER }}
  53. key: ${{ secrets.SSH_PRIVATE_KEY }}
  54. script: |
  55. ${{ secrets.SSH_SCRIPT }}