build.yml 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. branches:
  9. - develop
  10. tags:
  11. - v*
  12. env:
  13. IMAGE_NAME: ${{ github.repository }}
  14. REGISTRY: ghcr.io
  15. jobs:
  16. build:
  17. name: Build and publish
  18. runs-on: ubuntu-latest
  19. permissions:
  20. contents: read
  21. packages: write
  22. steps:
  23. - name: Checkout repository
  24. uses: actions/checkout@v4
  25. - name: Log in to registry
  26. uses: docker/login-action@v3
  27. with:
  28. registry: ghcr.io
  29. username: ${{ github.actor }}
  30. password: ${{ secrets.GITHUB_TOKEN }}
  31. - name: Extract image metadata
  32. id: meta
  33. uses: docker/metadata-action@v5
  34. with:
  35. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  36. - name: Build and push image
  37. uses: docker/build-push-action@v5
  38. with:
  39. labels: ${{ steps.meta.outputs.labels }}
  40. push: true
  41. tags: ${{ steps.meta.outputs.tags }}
  42. notify:
  43. name: Send Discord workflow notification
  44. runs-on: ubuntu-latest
  45. needs: build
  46. steps:
  47. - name: Send notification
  48. uses: annybs/action-notify-discord@v1
  49. if: ${{ always() }}
  50. with:
  51. repository: ${{ github.repository }}
  52. result: ${{ needs.build.result }}
  53. run-id: ${{ github.run_id }}
  54. run-number: ${{ github.run_number }}
  55. webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
  56. workflow: ${{ github.workflow }}