container-publish.yml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # This Source Code Form is subject to the terms of the Mozilla Public
  2. # License, v. 2.0. If a copy of the MPL was not distributed with this
  3. # file, You can obtain one at https://mozilla.org/MPL/2.0/.
  4. on:
  5. workflow_dispatch:
  6. push:
  7. branches: [ main ]
  8. pull_request:
  9. branches: [ main ]
  10. env:
  11. REGISTRY: ghcr.io
  12. IMAGE_NAME: selkies-project/nvidia-glx-desktop
  13. jobs:
  14. build:
  15. name: Build and push Ubuntu ${{ matrix.os_version }}
  16. runs-on: ubuntu-latest
  17. permissions:
  18. contents: read
  19. packages: write
  20. strategy:
  21. matrix:
  22. include:
  23. - os_version: "20.04"
  24. - os_version: "22.04"
  25. - os_version: "24.04"
  26. latest_tag: true
  27. steps:
  28. - name: Checkout repository
  29. uses: actions/checkout@v4
  30. - name: Fetch commit time
  31. run: echo "COMMIT_TIME_GIT=$(TZ=UTC git show -s --format='%cd' --date=format-local:'%Y%m%d%H%M%S')" >> "$GITHUB_ENV"
  32. - name: Set up QEMU
  33. uses: docker/setup-qemu-action@v3
  34. - name: Set up Docker Buildx
  35. uses: docker/setup-buildx-action@v3
  36. - name: Log into registry ${{ env.REGISTRY }}
  37. if: ${{ github.event_name != 'pull_request' }}
  38. uses: docker/login-action@v3
  39. with:
  40. registry: ${{ env.REGISTRY }}
  41. username: ${{ github.actor }}
  42. password: ${{ secrets.GITHUB_TOKEN }}
  43. - name: Extract container metadata
  44. id: meta
  45. uses: docker/metadata-action@v5
  46. with:
  47. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  48. - name: Build and push Ubuntu ${{ matrix.os_version }} container image
  49. uses: docker/build-push-action@v5
  50. with:
  51. build-args: |
  52. DISTRIB_RELEASE=${{ matrix.os_version }}
  53. context: .
  54. labels: ${{ steps.meta.outputs.labels }}
  55. no-cache: true
  56. push: ${{ github.event_name != 'pull_request' }}
  57. tags: |
  58. ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.os_version }}
  59. ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.os_version }}-${{ env.COMMIT_TIME_GIT }}
  60. ${{ matrix.latest_tag && format('{0}/{1}:latest', env.REGISTRY, env.IMAGE_NAME) || '' }}