docker-publish.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. # Use docker.io for Docker Hub if empty
  11. REGISTRY: docker.io
  12. # github.repository as <account>/<repo>
  13. IMAGE_NAME: byaidu/pdf2zh
  14. jobs:
  15. build:
  16. runs-on: ubuntu-latest
  17. permissions:
  18. contents: read
  19. packages: write
  20. # This is used to complete the identity challenge
  21. # with sigstore/fulcio when running outside of PRs.
  22. id-token: write
  23. steps:
  24. - name: Checkout repository
  25. uses: actions/checkout@v4
  26. # Install the cosign tool except on PR
  27. # https://github.com/sigstore/cosign-installer
  28. # Set up BuildKit Docker container builder to be able to build
  29. # multi-platform images and export cache
  30. # https://github.com/docker/setup-buildx-action
  31. - name: Set up Docker Buildx
  32. uses: docker/setup-buildx-action@v3
  33. # Login against a Docker registry except on PR
  34. # https://github.com/docker/login-action
  35. - name: Log into registry ${{ env.REGISTRY }}
  36. uses: docker/login-action@v3
  37. with:
  38. registry: ${{ env.REGISTRY }}
  39. username: ${{ secrets.DOCKER_USERNAME }}
  40. password: ${{ secrets.DOCKER_PASSWORD }}
  41. # Extract metadata (tags, labels) for Docker
  42. # https://github.com/docker/metadata-action
  43. - name: Extract Docker metadata
  44. id: meta
  45. uses: docker/metadata-action@v5
  46. with:
  47. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  48. # Build and push Docker image with Buildx (don't push on PR)
  49. # https://github.com/docker/build-push-action
  50. - name: Build and push Docker image
  51. id: build-and-push
  52. uses: docker/build-push-action@v6
  53. with:
  54. context: .
  55. push: true
  56. tags: ${{ steps.meta.outputs.tags }}
  57. labels: ${{ steps.meta.outputs.labels }}
  58. cache-from: type=gha
  59. cache-to: type=gha,mode=max