container.yaml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ---
  2. name: 'Build container'
  3. on:
  4. workflow_dispatch:
  5. pull_request:
  6. branches:
  7. - master
  8. paths:
  9. - container/**
  10. push:
  11. branches:
  12. - master
  13. paths:
  14. - container/**
  15. concurrency:
  16. group: ${{ github.workflow }}-${{ github.ref }}
  17. cancel-in-progress: true
  18. jobs:
  19. build:
  20. runs-on: ubuntu-latest
  21. permissions:
  22. contents: read
  23. packages: write
  24. steps:
  25. - name: Checkout
  26. uses: classabbyamp/treeless-checkout-action@v1
  27. - name: Get image release
  28. id: release
  29. run: |
  30. # gets the list of all date-shaped tags for the image, finds the most recent one
  31. tag="$(skopeo list-tags "docker://ghcr.io/${{ github.repository_owner }}/void-mklive" | \
  32. jq -r '.Tags | sort | reverse | map(select(test("^[0-9]{8}(R[0-9]+)?$")))[0]')"
  33. # tags from a different day or pre-YYYYMMDDRN
  34. if [ "${tag%R*}" != "$(date -u +%Y%m%d)" ] || [ "${tag%R*}" = "${tag}" ]; then
  35. rel=1
  36. else
  37. rel=$(( ${tag##*R} + 1 ))
  38. fi
  39. echo "rel=${rel}" >> "${GITHUB_OUTPUT}"
  40. - name: Docker metadata
  41. id: meta
  42. uses: docker/metadata-action@v4
  43. with:
  44. images: |
  45. ghcr.io/${{ github.repository_owner }}/void-mklive
  46. tags: |
  47. type=sha,prefix=
  48. type=raw,value=latest,enable={{is_default_branch}}
  49. type=raw,value={{date 'YYYYMMDD'}}R${{ steps.release.outputs.rel }},enable={{is_default_branch}},priority=1000
  50. flavor: latest=false
  51. labels: |
  52. org.opencontainers.image.authors=Void Linux team and contributors
  53. org.opencontainers.image.url=https://voidlinux.org
  54. org.opencontainers.image.documentation=https://github.com/${{ github.repository }}
  55. org.opencontainers.image.source=https://github.com/${{ github.repository }}
  56. org.opencontainers.image.vendor=Void Linux
  57. org.opencontainers.image.title=Void Linux mklive container
  58. org.opencontainers.image.description=Image for building mklive images
  59. - name: Set up Docker Buildx
  60. uses: docker/setup-buildx-action@v2
  61. - name: Login to GCHR
  62. if: github.event_name != 'pull_request'
  63. uses: docker/login-action@v2
  64. with:
  65. registry: ghcr.io
  66. username: ${{ github.actor }}
  67. password: ${{ secrets.GITHUB_TOKEN }}
  68. - name: Build and push images
  69. id: build_and_push
  70. uses: docker/bake-action@v3
  71. with:
  72. push: ${{ github.event_name != 'pull_request' }}
  73. targets: void-mklive
  74. files: |
  75. container/docker-bake.hcl
  76. ${{ steps.meta.outputs.bake-file }}
  77. set: |
  78. _common.cache-to=type=gha
  79. _common.cache-from=type=gha