docker-publish.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. name: Upload Docker Image
  2. # This workflow uses actions that are not certified by GitHub.
  3. # They are provided by a third-party and are governed by
  4. # separate terms of service, privacy policy, and support
  5. # documentation.
  6. on:
  7. release:
  8. types: [published]
  9. env:
  10. TARGET_PLATFORMS: linux/amd64,linux/arm64
  11. # Use docker.io for Docker Hub if empty
  12. REGISTRY: docker.io
  13. # github.repository as <account>/<repo>
  14. IMAGE_NAME: byaidu/pdf2zh
  15. jobs:
  16. build:
  17. runs-on: ubuntu-latest
  18. permissions:
  19. contents: read
  20. packages: write
  21. # This is used to complete the identity challenge
  22. # with sigstore/fulcio when running outside of PRs.
  23. id-token: write
  24. steps:
  25. - name: Checkout repository
  26. uses: actions/checkout@v4
  27. # Install the cosign tool except on PR
  28. # https://github.com/sigstore/cosign-installer
  29. # Set up BuildKit Docker container builder to be able to build
  30. # multi-platform images and export cache
  31. # https://github.com/docker/setup-buildx-action
  32. - name: Set up Docker Buildx
  33. uses: docker/setup-buildx-action@v3
  34. # Login against a Docker registry except on PR
  35. # https://github.com/docker/login-action
  36. - name: Log into registry ${{ env.REGISTRY }}
  37. uses: docker/login-action@v3
  38. with:
  39. registry: ${{ env.REGISTRY }}
  40. username: ${{ secrets.DOCKER_USERNAME }}
  41. password: ${{ secrets.DOCKER_PASSWORD }}
  42. # Extract metadata (tags, labels) for Docker
  43. # https://github.com/docker/metadata-action
  44. - name: Extract Docker metadata
  45. id: meta
  46. uses: docker/metadata-action@v5
  47. with:
  48. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  49. # Build and push Docker image with Buildx (don't push on PR)
  50. # https://github.com/docker/build-push-action
  51. - name: Build and push Docker image
  52. id: build-and-push
  53. uses: docker/build-push-action@v6
  54. with:
  55. context: .
  56. push: true
  57. tags: ${{ steps.meta.outputs.tags }}
  58. labels: ${{ steps.meta.outputs.labels }}
  59. cache-from: type=gha
  60. cache-to: type=gha,mode=max