container-publish.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. latest_tag: true
  26. steps:
  27. - name: Checkout repository
  28. uses: actions/checkout@v4
  29. - name: Fetch commit time
  30. run: echo "COMMIT_TIME_GIT=$(TZ=UTC git show -s --format='%cd' --date=format-local:'%Y%m%d%H%M%S')" >> "$GITHUB_ENV"
  31. - name: Log into registry ${{ env.REGISTRY }}
  32. if: ${{ github.event_name != 'pull_request' }}
  33. uses: docker/login-action@v3
  34. with:
  35. registry: ${{ env.REGISTRY }}
  36. username: ${{ github.actor }}
  37. password: ${{ secrets.GITHUB_TOKEN }}
  38. - name: Extract container metadata
  39. id: meta
  40. uses: docker/metadata-action@v5
  41. with:
  42. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  43. - name: Build and push Ubuntu ${{ matrix.os_version }} container image
  44. uses: docker/build-push-action@v5
  45. with:
  46. build-args: |
  47. UBUNTU_RELEASE=${{ matrix.os_version }}
  48. context: .
  49. push: ${{ github.event_name != 'pull_request' }}
  50. tags: |
  51. ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.os_version }}
  52. ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.os_version }}-${{ env.COMMIT_TIME_GIT }}
  53. ${{ matrix.latest_tag && format('{0}/{1}:latest', env.REGISTRY, env.IMAGE_NAME) || '' }}
  54. labels: ${{ steps.meta.outputs.labels }}