ci.yml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.10", "3.14.6", "3.15.4", "3.16.1" ]
  13. variant: [ "", "openrc" ]
  14. latest: [ false ]
  15. include:
  16. - alpine: 3.16.1
  17. variant: ""
  18. latest: true
  19. steps:
  20. - name: Checkout
  21. uses: actions/checkout@v2
  22. - uses: actions/github-script@v6
  23. id: alpine-minor-version
  24. with:
  25. # The script returns 1.15 from 1.15.10
  26. script: return "${{ matrix.alpine }}".substr(0, "${{ matrix.alpine }}".lastIndexOf("."))
  27. result-encoding: string
  28. - name: Docker metadata
  29. id: meta
  30. uses: docker/metadata-action@v4
  31. with:
  32. labels: |
  33. maintainer=The Dockage Developers
  34. images: |
  35. dockage/alpine
  36. tags: |
  37. type=raw,value=${{ matrix.alpine }},enable=${{ matrix.variant == '' }}
  38. type=raw,value=${{steps.alpine-minor-version.outputs.result}},enable=${{ matrix.variant == '' }}
  39. type=raw,value=${{ matrix.alpine }}-${{ matrix.variant }},enable=${{ matrix.variant != '' }}
  40. type=raw,value=${{steps.alpine-minor-version.outputs.result}}-${{ matrix.variant }},enable=${{ matrix.variant != '' }}
  41. type=raw,value=latest,enable=${{ matrix.latest }}
  42. - name: Set up Docker Buildx
  43. uses: docker/setup-buildx-action@v2
  44. - name: Login to DockerHub
  45. if: ${{ github.event_name != 'pull_request' }}
  46. uses: docker/login-action@v2
  47. with:
  48. username: ${{ secrets.DOCKERHUB_USERNAME }}
  49. password: ${{ secrets.DOCKERHUB_TOKEN }}
  50. - name: Build images
  51. uses: docker/bake-action@v2
  52. with:
  53. push: ${{ github.ref_name == github.event.repository.default_branch }}
  54. targets: ${{ matrix.variant }}
  55. files: |
  56. ./docker-bake.hcl
  57. ${{ steps.meta.outputs.bake-file }}
  58. env:
  59. CONTEXT: ${{steps.alpine-minor-version.outputs.result}}
  60. - name: Docker Hub Description
  61. uses: peter-evans/dockerhub-description@v3
  62. if: ${{ github.event_name == 'push' && github.ref_name == github.event.repository.default_branch }}
  63. with:
  64. username: ${{ secrets.DOCKERHUB_USERNAME }}
  65. password: ${{ secrets.DOCKERHUB_TOKEN }}
  66. short-description: ${{ github.event.repository.description }}