docker.yml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. name: Publish Docker image
  2. on:
  3. workflow_dispatch:
  4. release:
  5. types: [published]
  6. jobs:
  7. push_to_registry:
  8. name: Push Docker image to registry
  9. runs-on: ubuntu-latest
  10. permissions:
  11. contents: read
  12. packages: write
  13. steps:
  14. - name: Check out the repo
  15. uses: actions/checkout@v3
  16. - name: Login to GitHub Container Registry
  17. uses: docker/login-action@v2
  18. with:
  19. registry: ghcr.io
  20. username: ${{ github.repository_owner }}
  21. password: ${{ secrets.GITHUB_TOKEN }}
  22. - name: Set up QEMU
  23. uses: docker/setup-qemu-action@v2
  24. - name: Set up Docker Buildx
  25. uses: docker/setup-buildx-action@v2
  26. - name: Docker metadata(ghcr)
  27. id: meta
  28. uses: docker/metadata-action@v4
  29. with:
  30. images: ghcr.io/${{ github.repository_owner }}/node-chatgpt-api
  31. tags: |
  32. type=raw,value=latest
  33. type=sha,format=long
  34. - name: Build and push Docker image(ghcr)
  35. uses: docker/build-push-action@v4
  36. with:
  37. context: .
  38. platforms: linux/amd64,linux/arm64
  39. push: true
  40. tags: ${{ steps.meta.outputs.tags }}
  41. labels: ${{ steps.meta.outputs.labels }}
  42. cache-from: type=gha
  43. cache-to: type=gha,mode=max