ci.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. name: CI
  2. on:
  3. push:
  4. branches: [ "master" ]
  5. pull_request:
  6. branches: [ "*" ]
  7. jobs:
  8. docker:
  9. runs-on: ubuntu-latest
  10. strategy:
  11. matrix:
  12. alpine: [ "3.13.12", "3.14.8", "3.15.6", "3.16.2" ]
  13. variant: [ "", "openrc" ]
  14. latest: [ false ]
  15. include:
  16. - alpine: "3.16.2"
  17. variant: ""
  18. latest: true
  19. - alpine: "3.16.2"
  20. variant: "openrc"
  21. latest: true
  22. steps:
  23. - name: Checkout
  24. uses: actions/checkout@v2
  25. - uses: actions/github-script@v6
  26. id: alpine-minor-version
  27. with:
  28. # The script returns 1.15 from 1.15.10
  29. script: return "${{ matrix.alpine }}".substr(0, "${{ matrix.alpine }}".lastIndexOf("."))
  30. result-encoding: string
  31. - name: Docker metadata
  32. id: meta
  33. uses: docker/metadata-action@v4
  34. with:
  35. labels: |
  36. maintainer=The Dockage Developers
  37. images: |
  38. dockage/alpine
  39. flavor: |
  40. latest=false
  41. suffix=${{ format(matrix.variant != '' && '-{0}' || '', matrix.variant) }}
  42. tags: |
  43. ### versioning strategy
  44. # dockage/alpine:3.16.2
  45. # dockage/alpine:3.16
  46. # dockage/alpine:3
  47. # dockage/alpine:3.16.2-openrc
  48. # dockage/alpine:3.16-openrc
  49. # dockage/alpine:3-openrc
  50. # dockage/alpine:latest
  51. type=semver,pattern={{version}},value=${{ matrix.alpine }}
  52. type=semver,pattern={{major}}.{{minor}},value=${{ matrix.alpine }}
  53. type=semver,pattern={{major}},value=${{ matrix.alpine }},enable=${{ matrix.latest }}
  54. type=raw,value=latest,suffix=,enable=${{ matrix.latest && matrix.variant == '' }}
  55. - name: Set up Docker Buildx
  56. uses: docker/setup-buildx-action@v2
  57. - name: Login to DockerHub
  58. if: ${{ github.event_name != 'pull_request' }}
  59. uses: docker/login-action@v2
  60. with:
  61. username: ${{ secrets.DOCKERHUB_USERNAME }}
  62. password: ${{ secrets.DOCKERHUB_TOKEN }}
  63. - name: Build images
  64. uses: docker/bake-action@v2
  65. with:
  66. push: ${{ github.ref_name == github.event.repository.default_branch }}
  67. targets: ${{ matrix.variant }}
  68. files: |
  69. ./docker-bake.hcl
  70. ${{ steps.meta.outputs.bake-file }}
  71. env:
  72. CONTEXT: ${{steps.alpine-minor-version.outputs.result}}
  73. - name: Docker Hub Description
  74. uses: peter-evans/dockerhub-description@v3
  75. if: ${{ github.event_name == 'push' && github.ref_name == github.event.repository.default_branch }}
  76. with:
  77. username: ${{ secrets.DOCKERHUB_USERNAME }}
  78. password: ${{ secrets.DOCKERHUB_TOKEN }}
  79. short-description: ${{ github.event.repository.description }}