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: '29 3 5 * *'
  9. push:
  10. branches: [ master ]
  11. # Publish semver tags as releases.
  12. tags: [ 'v*.*.*' ]
  13. pull_request:
  14. branches: [ master ]
  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@v2
  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@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
  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@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
  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@ad44023a93711e3deb337508980b4b5e9bcdc5dc
  49. with:
  50. context: .
  51. push: ${{ github.event_name != 'pull_request' }}
  52. tags: ${{ steps.meta.outputs.tags }}
  53. labels: ${{ steps.meta.outputs.labels }}