docker-publish.yml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. name: Docker
  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. schedule:
  8. - cron: '28 23 * * *'
  9. push:
  10. branches: [ main ]
  11. # Publish semver tags as releases.
  12. tags: [ 'v*.*.*' ]
  13. pull_request:
  14. branches: [ main ]
  15. env:
  16. # Use docker.io for Docker Hub if empty
  17. REGISTRY: ghcr.io
  18. # github.repository as <account>/<repo>
  19. IMAGE_NAME: ${{ github.repository }}
  20. jobs:
  21. build:
  22. runs-on: ubuntu-latest
  23. permissions:
  24. contents: read
  25. packages: write
  26. steps:
  27. - name: Checkout repository
  28. uses: actions/checkout@v4
  29. # Login against a Docker registry except on PR
  30. # https://github.com/docker/login-action
  31. - name: Log into registry ${{ env.REGISTRY }}
  32. if: github.event_name != 'pull_request'
  33. uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
  34. with:
  35. registry: ${{ env.REGISTRY }}
  36. username: ${{ github.actor }}
  37. password: ${{ secrets.GITHUB_TOKEN }}
  38. # Extract metadata (tags, labels) for Docker
  39. # https://github.com/docker/metadata-action
  40. - name: Extract Docker metadata
  41. id: meta
  42. uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804
  43. with:
  44. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  45. # Build and push Docker image with Buildx (don't push on PR)
  46. # https://github.com/docker/build-push-action
  47. - name: Build and push Docker image
  48. uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0
  49. with:
  50. context: .
  51. push: ${{ github.event_name != 'pull_request' }}
  52. tags: ${{ steps.meta.outputs.tags }}
  53. labels: ${{ steps.meta.outputs.labels }}