1
0

build.yml 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. environment: ${{ inputs.environment }}
  18. steps:
  19. - name: Checkout repository
  20. uses: actions/checkout@v4
  21. - name: Log in to registry
  22. uses: docker/login-action@v3
  23. with:
  24. registry: ghcr.io
  25. username: ${{ github.actor }}
  26. password: ${{ secrets.GITHUB_TOKEN }}
  27. - name: Extract image metadata
  28. id: meta
  29. uses: docker/metadata-action@v5
  30. with:
  31. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  32. - name: Build and push image
  33. uses: docker/build-push-action@v5
  34. with:
  35. labels: ${{ steps.meta.outputs.labels }}
  36. push: true
  37. tags: ${{ steps.meta.outputs.tags }}