build.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. name: Build
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - master
  7. paths-ignore:
  8. - '**/*.md'
  9. - '**/*.yml'
  10. - '.gitignore'
  11. - '.dockerignore'
  12. - '.github/**'
  13. - '.github/workflows/**'
  14. concurrency:
  15. group: build
  16. cancel-in-progress: false
  17. jobs:
  18. shellcheck:
  19. name: Test
  20. uses: ./.github/workflows/check.yml
  21. build:
  22. name: Build
  23. needs: shellcheck
  24. runs-on: ubuntu-latest
  25. permissions:
  26. actions: write
  27. packages: write
  28. contents: read
  29. steps:
  30. -
  31. name: Checkout
  32. uses: actions/checkout@v4
  33. with:
  34. fetch-depth: 0
  35. -
  36. name: Docker metadata
  37. id: meta
  38. uses: docker/metadata-action@v5
  39. with:
  40. context: git
  41. images: |
  42. ${{ secrets.DOCKERHUB_REPO }}
  43. ghcr.io/${{ github.repository }}
  44. tags: |
  45. type=raw,value=latest,priority=100
  46. type=raw,value=${{ vars.MAJOR }}.${{ vars.MINOR }}
  47. labels: |
  48. org.opencontainers.image.title=${{ vars.NAME }}
  49. env:
  50. DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
  51. -
  52. name: Set up Docker Buildx
  53. uses: docker/setup-buildx-action@v3
  54. -
  55. name: Login into Docker Hub
  56. uses: docker/login-action@v3
  57. with:
  58. username: ${{ secrets.DOCKERHUB_USERNAME }}
  59. password: ${{ secrets.DOCKERHUB_TOKEN }}
  60. -
  61. name: Login to GitHub Container Registry
  62. uses: docker/login-action@v3
  63. with:
  64. registry: ghcr.io
  65. username: ${{ github.actor }}
  66. password: ${{ secrets.GITHUB_TOKEN }}
  67. -
  68. name: Build Docker image
  69. uses: docker/build-push-action@v6
  70. with:
  71. context: .
  72. push: true
  73. provenance: false
  74. platforms: linux/amd64,linux/arm64
  75. tags: ${{ steps.meta.outputs.tags }}
  76. labels: ${{ steps.meta.outputs.labels }}
  77. annotations: ${{ steps.meta.outputs.annotations }}
  78. build-args: |
  79. VERSION_ARG=${{ steps.meta.outputs.version }}
  80. -
  81. name: Create a release
  82. uses: action-pack/github-release@v2
  83. with:
  84. tag: "v${{ steps.meta.outputs.version }}"
  85. title: "v${{ steps.meta.outputs.version }}"
  86. token: ${{ secrets.REPO_ACCESS_TOKEN }}
  87. -
  88. name: Increment version variable
  89. uses: action-pack/bump@v2
  90. with:
  91. token: ${{ secrets.REPO_ACCESS_TOKEN }}
  92. -
  93. name: Push to Gitlab mirror
  94. uses: action-pack/gitlab-sync@v3
  95. with:
  96. url: ${{ secrets.GITLAB_URL }}
  97. token: ${{ secrets.GITLAB_TOKEN }}
  98. username: ${{ secrets.GITLAB_USERNAME }}
  99. -
  100. name: Send mail
  101. uses: action-pack/send-mail@v1
  102. with:
  103. to: ${{secrets.MAILTO}}
  104. from: Github Actions <${{secrets.MAILTO}}>
  105. connection_url: ${{secrets.MAIL_CONNECTION}}
  106. subject: Build of ${{ github.event.repository.name }} v${{ steps.meta.outputs.version }} completed
  107. body: |
  108. The build job of ${{ github.event.repository.name }} v${{ steps.meta.outputs.version }} was completed successfully!
  109. See https://github.com/${{ github.repository }}/actions for more information.