docker-image-api.yml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. name: API Docker Image CI
  2. on:
  3. push:
  4. paths-ignore:
  5. - 'playground-ui/**'
  6. branches:
  7. - 'main'
  8. release:
  9. types: [ published ]
  10. env:
  11. IMAGE_NAME: 'samepaage/open-assistant-api'
  12. jobs:
  13. build-and-push:
  14. runs-on: ubuntu-latest
  15. permissions:
  16. packages: write
  17. contents: read
  18. steps:
  19. - uses: actions/checkout@v4
  20. - name: Set up QEMU
  21. uses: docker/setup-qemu-action@v3
  22. - name: Set up Docker Buildx
  23. uses: docker/setup-buildx-action@v3
  24. - name: Login to DockerHub
  25. uses: docker/login-action@v2
  26. with:
  27. username: ${{ secrets.DOCKERHUB_USER }}
  28. password: ${{ secrets.DOCKERHUB_TOKEN }}
  29. - name: Extract metadata (tags, labels) for Docker
  30. id: meta
  31. uses: docker/metadata-action@v5
  32. with:
  33. images: ${{ env.IMAGE_NAME }}
  34. tags: |
  35. type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
  36. type=ref,event=branch
  37. type=sha,enable=true,priority=100,prefix=,suffix=,format=long
  38. type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
  39. - name: Build and push
  40. uses: docker/build-push-action@v5
  41. with:
  42. platforms: |
  43. linux/amd64
  44. linux/arm64
  45. build-args: |
  46. COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
  47. push: true
  48. tags: ${{ steps.meta.outputs.tags }}
  49. labels: ${{ steps.meta.outputs.labels }}
  50. cache-from: type=gha
  51. cache-to: type=gha,mode=max