container-publish.yml 2.1 KB

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