build.yml 1.6 KB

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