71 line
2.0KB

  1. # This workflow uses actions that are not certified by GitHub.
  2. # They are provided by a third-party and are governed by
  3. # separate terms of service, privacy policy, and support
  4. # documentation.
  5. # GitHub recommends pinning actions to a commit SHA.
  6. # To get a newer version, you will need to update the SHA.
  7. # You can also reference a tag or branch, but the action may change without warning.
  8. name: Create and publish a Docker image
  9. on:
  10. push:
  11. branches: ['master']
  12. create:
  13. env:
  14. REGISTRY: ghcr.io
  15. IMAGE_NAME: ${{ github.repository }}
  16. jobs:
  17. build-and-push-image:
  18. runs-on: ubuntu-latest
  19. permissions:
  20. contents: read
  21. packages: write
  22. steps:
  23. - name: Checkout repository
  24. uses: actions/checkout@v3
  25. - name: Set up QEMU
  26. uses: docker/setup-qemu-action@v1
  27. - name: Set up Docker Buildx
  28. id: buildx
  29. uses: docker/setup-buildx-action@v1
  30. - name: Available platforms
  31. run: echo ${{ steps.buildx.outputs.platforms }}
  32. - name: Log in to the Container registry
  33. uses: docker/login-action@v2
  34. with:
  35. registry: ${{ env.REGISTRY }}
  36. username: ${{ github.actor }}
  37. password: ${{ secrets.GITHUB_TOKEN }}
  38. - name: Extract metadata (tags, labels) for Docker
  39. id: meta
  40. uses: docker/metadata-action@v4
  41. with:
  42. images: |
  43. ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  44. - name: Build and push Docker image
  45. uses: docker/build-push-action@v3
  46. with:
  47. context: .
  48. push: true
  49. file: ./docker/Dockerfile.latest
  50. platforms: linux/arm64
  51. tags: ${{ steps.meta.outputs.tags }}-arm64
  52. labels: ${{ steps.meta.outputs.labels }}
  53. - uses: actions/delete-package-versions@v4
  54. with:
  55. package-name: 'chatgpt-on-wechat'
  56. package-type: 'container'
  57. min-versions-to-keep: 10
  58. delete-only-untagged-versions: 'true'
  59. token: ${{ secrets.GITHUB_TOKEN }}