docker-publish.yml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. name: Docker
  2. on:
  3. schedule:
  4. - cron: '0 0 * * *'
  5. push:
  6. branches: [ main ]
  7. tags: [ 'latest' ]
  8. pull_request:
  9. branches: [ main ]
  10. env:
  11. REGISTRY: ghcr.io
  12. IMAGE_NAME: ${{ github.repository }}
  13. jobs:
  14. build:
  15. runs-on: ubuntu-latest
  16. permissions:
  17. contents: read
  18. packages: write
  19. steps:
  20. - name: Checkout repository
  21. uses: actions/checkout@v2
  22. - name: Log into registry ${{ env.REGISTRY }}
  23. if: github.event_name != 'pull_request'
  24. uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
  25. with:
  26. registry: ${{ env.REGISTRY }}
  27. username: ${{ github.actor }}
  28. password: ${{ secrets.GITHUB_TOKEN }}
  29. - name: Extract Docker metadata
  30. id: meta
  31. uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
  32. with:
  33. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  34. - name: Build and push Docker image
  35. uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
  36. with:
  37. context: .
  38. push: ${{ github.event_name != 'pull_request' }}
  39. tags: ${{ steps.meta.outputs.tags }}
  40. labels: ${{ steps.meta.outputs.labels }}