build.yml 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Build and publish to GitHub Container Registry
  2. #
  3. # https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#publishing-a-package-using-an-action
  4. name: Build Docker image
  5. on:
  6. workflow_dispatch:
  7. push:
  8. tags:
  9. - v*
  10. env:
  11. IMAGE_NAME: ${{ github.repository }}
  12. REGISTRY: ghcr.io
  13. jobs:
  14. build:
  15. name: Build and publish
  16. runs-on: ubuntu-latest
  17. permissions:
  18. contents: read
  19. packages: write
  20. steps:
  21. - name: Checkout repository
  22. uses: actions/checkout@v4
  23. - name: Log in to registry
  24. uses: docker/login-action@v3
  25. with:
  26. registry: ghcr.io
  27. username: ${{ github.actor }}
  28. password: ${{ secrets.GITHUB_TOKEN }}
  29. - name: Extract image metadata
  30. id: meta
  31. uses: docker/metadata-action@v5
  32. with:
  33. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  34. - name: Build and push image
  35. uses: docker/build-push-action@v5
  36. with:
  37. labels: ${{ steps.meta.outputs.labels }}
  38. push: true
  39. tags: ${{ steps.meta.outputs.tags }}