build.yml 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 and publish
  5. concurrency:
  6. group: build-${{ github.ref }}
  7. cancel-in-progress: true
  8. on:
  9. workflow_dispatch:
  10. push:
  11. branches:
  12. - develop
  13. paths:
  14. - .github/workflows/build.yml
  15. - Dockerfile
  16. - go.mod
  17. - go.sum
  18. - main.go
  19. env:
  20. IMAGE_NAME: ${{ github.repository }}
  21. REGISTRY: ghcr.io
  22. jobs:
  23. build:
  24. name: Build and publish
  25. runs-on: ubuntu-latest
  26. steps:
  27. - name: Checkout repository
  28. uses: actions/checkout@v4
  29. - name: Log in to registry
  30. uses: docker/login-action@v3
  31. with:
  32. registry: ghcr.io
  33. username: ${{ github.actor }}
  34. password: ${{ secrets.GITHUB_TOKEN }}
  35. - name: Extract image metadata
  36. id: meta
  37. uses: docker/metadata-action@v5
  38. with:
  39. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  40. - name: Build and push image
  41. uses: docker/build-push-action@v5
  42. with:
  43. labels: ${{ steps.meta.outputs.labels }}
  44. push: true
  45. tags: ${{ steps.meta.outputs.tags }}
  46. # https://github.com/recipeer/docs/blob/develop/workflows/discord-notifications.md
  47. notify:
  48. name: Discord notification
  49. uses: recipeer/docs/.github/workflows/discord.yml@develop
  50. needs: build
  51. secrets: inherit
  52. if: ${{ always() }}
  53. with:
  54. repository: ${{ github.repository }}
  55. result: ${{ needs.build.result }}
  56. run_id: ${{ github.run_id }}
  57. run_number: ${{ github.run_number }}
  58. workflow: ${{ github.workflow }}